mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
@@ -64,23 +64,7 @@ npm test
|
||||
|
||||
3. Open [http://localhost:8511/bin/qunit-runner.html](http://localhost:8511/bin/qunit-runner.html) in your browser.
|
||||
|
||||
#### Visual Test
|
||||
|
||||
1. Build for testing.<br>
|
||||
|
||||
```bash
|
||||
gulp build-test
|
||||
```
|
||||
|
||||
2. Start express in cloned project folder.
|
||||
|
||||
```
|
||||
node test/visual-tests/server.js
|
||||
```
|
||||
|
||||
3. Open [http://localhost:8512/test/visual-tests/index.html](http://localhost:8512/test/visual-tests/index.html) in your browser.
|
||||
|
||||
### DebugInfos
|
||||
### DebugInfos
|
||||
|
||||
View [EngineErrorMap.md](https://github.com/cocos-creator/engine/blob/master/EngineErrorMap.md)
|
||||
All the debug infos are defined in file EngineErrorMap.md.
|
||||
|
||||
+21
-8
@@ -251,7 +251,10 @@ var Model = cc.Class({
|
||||
vcount
|
||||
);
|
||||
|
||||
return vb;
|
||||
return {
|
||||
buffer: vb,
|
||||
data: vbData
|
||||
};
|
||||
},
|
||||
|
||||
createSkinning(index) {
|
||||
@@ -293,18 +296,21 @@ var Model = cc.Class({
|
||||
const accessors = gltf.accessors;
|
||||
|
||||
// create index-buffer
|
||||
meshAsset._subMeshes.length = gltfMesh.primitives.length;
|
||||
for (let i = 0; i < gltfMesh.primitives.length; ++i) {
|
||||
let length = gltfMesh.primitives.length;
|
||||
meshAsset._ibs.length = length;
|
||||
meshAsset._vbs.length = length;
|
||||
meshAsset._subMeshes.length = length;
|
||||
for (let i = 0; i < length; ++i) {
|
||||
let primitive = gltfMesh.primitives[i];
|
||||
|
||||
if (primitive.indices === undefined) continue;
|
||||
|
||||
let vb = this._createVB(bin, gltf, accessors, primitive.attributes);
|
||||
|
||||
let ibAcc = accessors[primitive.indices];
|
||||
let ibView = gltf.bufferViews[ibAcc.bufferView];
|
||||
let ibData = new Uint8Array(bin, ibView.byteOffset, ibView.byteLength);
|
||||
|
||||
let vb = this._createVB(bin, gltf, accessors, primitive.attributes);
|
||||
let ib = new gfx.IndexBuffer(
|
||||
let ibData = new Uint16Array(bin, ibView.byteOffset, ibView.byteLength/2);
|
||||
let ibBuffer = new gfx.IndexBuffer(
|
||||
renderer.device,
|
||||
ibAcc.componentType,
|
||||
gfx.USAGE_STATIC,
|
||||
@@ -312,7 +318,14 @@ var Model = cc.Class({
|
||||
ibAcc.count
|
||||
);
|
||||
|
||||
meshAsset._subMeshes[i] = new renderEngine.InputAssembler(vb, ib);
|
||||
let ib = {
|
||||
buffer: ibBuffer,
|
||||
data: ibData
|
||||
}
|
||||
|
||||
meshAsset._subMeshes[i] = new renderEngine.InputAssembler(vb.buffer, ibBuffer);
|
||||
meshAsset._vbs[i] = vb;
|
||||
meshAsset._ibs[i] = ib;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -41,6 +41,10 @@ var SkeletonAnimation = cc.Class({
|
||||
name: 'cc.SkeletonAnimation',
|
||||
extends: Animation,
|
||||
|
||||
editor: CC_EDITOR && {
|
||||
inspector: 'packages://inspector/inspectors/comps/skeleton-animation.js',
|
||||
},
|
||||
|
||||
properties: {
|
||||
_model: Model,
|
||||
_nodes: [cc.Node],
|
||||
@@ -82,6 +86,30 @@ var SkeletonAnimation = cc.Class({
|
||||
let clip = state.clip;
|
||||
clip.init(this._nodes);
|
||||
return state;
|
||||
},
|
||||
|
||||
searchClips: CC_EDITOR && function () {
|
||||
this._clips.length = 0;
|
||||
let self = this;
|
||||
Editor.assetdb.queryPathByUuid(this._model._uuid, function (err, modelPath) {
|
||||
if (err) return console.error(err);
|
||||
|
||||
const Path = require('fire-path');
|
||||
let queryPath = Path.relative(Editor.remote.Project.path, modelPath);
|
||||
queryPath = Path.join(Path.dirname(queryPath), Path.basenameNoExt(queryPath));
|
||||
queryPath = `db://${queryPath}*/*.sac`;
|
||||
|
||||
Editor.assetdb.queryAssets(queryPath, null, function (err, results) {
|
||||
if (results) {
|
||||
for (let i = 0; i < results.length; i++) {
|
||||
let clip = new SkeletonAnimationClip();
|
||||
clip._uuid = results[i].uuid;
|
||||
self._clips.push(clip);
|
||||
}
|
||||
self._defaultClip = self._clips[0];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ const Model = require('./CCModel');
|
||||
*/
|
||||
/**
|
||||
* !#en SkeletonAnimationClip Asset.
|
||||
* !#zh 网格资源。
|
||||
* !#zh 骨骼动画剪辑。
|
||||
* @class SkeletonAnimationClip
|
||||
* @extends AnimationClip
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
const MeshRenderer = require('../components/CCMeshRenderer');
|
||||
const MeshRenderer = require('../mesh/CCMeshRenderer');
|
||||
const renderEngine = require('../renderer/render-engine');
|
||||
const mat4 = cc.vmath.mat4;
|
||||
|
||||
|
||||
@@ -246,15 +246,17 @@ function _update3DFunction () {
|
||||
this._updateLocalMatrix = _updateLocalMatrix3d;
|
||||
this._calculWorldMatrix = _calculWorldMatrix3d;
|
||||
this._mulMat = cc.vmath.mat4.mul;
|
||||
this._syncEulerAngles = _syncEulerAngles;
|
||||
}
|
||||
else {
|
||||
this._updateLocalMatrix = _updateLocalMatrix2d;
|
||||
this._calculWorldMatrix = _calculWorldMatrix2d;
|
||||
this._mulMat = _mulMat2d;
|
||||
this._syncEulerAngles = _syncEulerAngles2d;
|
||||
}
|
||||
}
|
||||
|
||||
function _apply3DNode () {
|
||||
function _upgrade_1x_to_2x () {
|
||||
if (CC_EDITOR && this instanceof cc.Scene) {
|
||||
this._is3DNode = true;
|
||||
}
|
||||
@@ -263,12 +265,15 @@ function _apply3DNode () {
|
||||
this._update3DFunction();
|
||||
}
|
||||
|
||||
this._syncEulerAngles();
|
||||
_upgrade_1x_to_2x_2d.call(this);
|
||||
}
|
||||
|
||||
|
||||
let proto = cc.Node.prototype;
|
||||
const _updateLocalMatrix2d = proto._updateLocalMatrix;
|
||||
const _calculWorldMatrix2d = proto._calculWorldMatrix;
|
||||
const _upgrade_1x_to_2x_2d = proto._upgrade_1x_to_2x;
|
||||
const _syncEulerAngles2d = proto._syncEulerAngles;
|
||||
const _mulMat2d = proto._mulMat;
|
||||
const _onBatchCreated2d = proto._onBatchCreated;
|
||||
|
||||
@@ -280,8 +285,7 @@ proto.setPosition = setPosition;
|
||||
proto.getScale = getScale;
|
||||
proto.setScale = setScale;
|
||||
|
||||
proto._upgrade_1x_to_2x = _apply3DNode;
|
||||
proto._syncEulerAngles = _syncEulerAngles;
|
||||
proto._upgrade_1x_to_2x = _upgrade_1x_to_2x;
|
||||
proto._update3DFunction = _update3DFunction;
|
||||
|
||||
cc.js.getset(proto, 'position', getPosition, setPosition, false, true);
|
||||
@@ -293,6 +297,7 @@ cc.js.getset(proto, 'is3DNode', function () {
|
||||
if (this._is3DNode === v) return;
|
||||
this._is3DNode = v;
|
||||
this._update3DFunction();
|
||||
this._syncEulerAngles();
|
||||
});
|
||||
|
||||
cc.js.getset(proto, 'quat', getQuat, setQuat);
|
||||
|
||||
@@ -218,6 +218,12 @@ if (CC_DEBUG) {
|
||||
'CONFIG_KEY',
|
||||
], 'cc.game');
|
||||
|
||||
// cc.sys
|
||||
markAsRemovedInObject(cc.sys, [
|
||||
'dumpRoot',
|
||||
'cleanScript',
|
||||
], 'cc.sys');
|
||||
|
||||
// cc.Director
|
||||
provideClearError(cc.Director, {
|
||||
EVENT_PROJECTION_CHANGED: '',
|
||||
@@ -302,7 +308,7 @@ if (CC_DEBUG) {
|
||||
'getTag': 'name',
|
||||
'setTag': 'name',
|
||||
'getChildByTag': 'getChildByName',
|
||||
'removeChildByTag': 'removeChildByName'
|
||||
'removeChildByTag': 'getChildByName(name).destroy()'
|
||||
});
|
||||
|
||||
markAsRemoved(cc.Node, [
|
||||
|
||||
@@ -36,10 +36,8 @@ module.exports = {
|
||||
let matrix = node._worldMatrix;
|
||||
let a = matrix.m00, b = matrix.m01, c = matrix.m04, d = matrix.m05,
|
||||
tx = matrix.m12, ty = matrix.m13;
|
||||
ctx.transform(a, b, c, d, tx, -ty);
|
||||
|
||||
ctx.transform(a, b, c, d, tx, ty);
|
||||
ctx.save();
|
||||
ctx.scale(1, -1);
|
||||
|
||||
// TODO: handle blend function
|
||||
|
||||
|
||||
@@ -0,0 +1,281 @@
|
||||
/****************************************************************************
|
||||
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.
|
||||
****************************************************************************/
|
||||
|
||||
const renderer = require('../renderer');
|
||||
const renderEngine = require('../renderer/render-engine');
|
||||
const gfx = renderEngine.gfx;
|
||||
|
||||
function applyColor (data, offset, value) {
|
||||
data[offset] = value._val;
|
||||
}
|
||||
|
||||
function applyVec2 (data, offset, value) {
|
||||
data[offset] = value.x;
|
||||
data[offset+1] = value.y;
|
||||
}
|
||||
|
||||
function applyVec3 (data, offset, value) {
|
||||
data[offset] = value.x;
|
||||
data[offset+1] = value.y;
|
||||
data[offset+2] = value.z;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @module cc
|
||||
*/
|
||||
/**
|
||||
* !#en Mesh Asset.
|
||||
* !#zh 网格资源。
|
||||
* @class Mesh
|
||||
* @extends Asset
|
||||
*/
|
||||
var Mesh = cc.Class({
|
||||
name: 'cc.Mesh',
|
||||
extends: cc.Asset,
|
||||
|
||||
properties: {
|
||||
_modelSetter: {
|
||||
set: function (model) {
|
||||
this._initWithModel(model);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en Get ir set the sub meshes.
|
||||
* !#zh 设置或者获取子网格。
|
||||
* @property {[renderEngine.InputAssembler]} subMeshes
|
||||
*/
|
||||
subMeshes: {
|
||||
get () {
|
||||
return this._subMeshes;
|
||||
},
|
||||
set (v) {
|
||||
this._subMeshes = v;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
ctor () {
|
||||
this._modelUuid = '';
|
||||
this._meshID = -1;
|
||||
this._model = null;
|
||||
|
||||
this._subMeshes = [];
|
||||
|
||||
this._ibs = [];
|
||||
this._vbs = [];
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Init vertex buffer according to the vertex format.
|
||||
* !#zh
|
||||
* 根据顶点格式初始化顶点内存。
|
||||
* @method init
|
||||
* @param {gfx.VertexFormat} vertexFormat - vertex format
|
||||
* @param {Number} vertexCount - how much vertex should be create in this buffer.
|
||||
* @param {Boolean} dynamic - whether or not to use dynamic buffer.
|
||||
*/
|
||||
init (vertexFormat, vertexCount, dynamic) {
|
||||
this.clear();
|
||||
|
||||
let data = new Uint8Array(vertexFormat._bytes*vertexCount);
|
||||
let vb = new gfx.VertexBuffer(
|
||||
renderer.device,
|
||||
vertexFormat,
|
||||
dynamic ? gfx.USAGE_STATIC : gfx.USAGE_DYNAMIC,
|
||||
data,
|
||||
vertexCount
|
||||
);
|
||||
|
||||
this._vbs[0] = {
|
||||
buffer: vb,
|
||||
data: data,
|
||||
float32Data: new Float32Array(data.buffer),
|
||||
uint32Data: new Uint32Array(data.buffer),
|
||||
dirty: true
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Set the vertex values.
|
||||
* !#zh
|
||||
* 设置顶点数据
|
||||
* @method setVertexes
|
||||
* @param {String} name - the attribute name, e.g. gfx.ATTR_POSITION
|
||||
* @param {[Vec2|Vec3|Color]} values - the vertex values
|
||||
* @param {Number} [index]
|
||||
*/
|
||||
setVertexes (name, values, index) {
|
||||
index = index || 0;
|
||||
let vb = this._vbs[index];
|
||||
|
||||
let buffer = vb.buffer;
|
||||
let el = buffer._format._attr2el[name];
|
||||
if (!el) {
|
||||
return cc.warn(`Cannot find ${name} attribute in vertex defines.`);
|
||||
}
|
||||
|
||||
let stride = el.stride/4;
|
||||
let offset = el.offset/4;
|
||||
|
||||
let data;
|
||||
let applyFunc;
|
||||
if (name === gfx.ATTR_COLOR) {
|
||||
data = vb.uint32Data;
|
||||
applyFunc = applyColor;
|
||||
}
|
||||
else {
|
||||
data = vb.float32Data;
|
||||
if (el.num === 2) {
|
||||
applyFunc = applyVec2;
|
||||
}
|
||||
else {
|
||||
applyFunc = applyVec3;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0, l = values.length; i < l; i++) {
|
||||
let v = values[i];
|
||||
let vOffset = i * stride + offset;
|
||||
applyFunc(data, vOffset, v);
|
||||
}
|
||||
vb.dirty = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Set the sub mesh indices.
|
||||
* !#zh
|
||||
* 设置子网格索引。
|
||||
* @method setIndices
|
||||
* @param {[Number]} indices - the sub mesh indices.
|
||||
* @param {Number} index - sub mesh index.
|
||||
*/
|
||||
setIndices (indices, index) {
|
||||
index = index || 0;
|
||||
|
||||
let data = new Uint16Array(indices);
|
||||
|
||||
let ib = this._ibs[index];
|
||||
if (!ib) {
|
||||
let buffer = new gfx.IndexBuffer(
|
||||
renderer.device,
|
||||
gfx.INDEX_FMT_UINT16,
|
||||
gfx.USAGE_STATIC,
|
||||
data,
|
||||
data.length
|
||||
);
|
||||
|
||||
this._ibs[index] = {
|
||||
buffer: buffer,
|
||||
data: data,
|
||||
dirty: false
|
||||
};
|
||||
|
||||
let vb = this._vbs[0];
|
||||
this._subMeshes[index] = new renderEngine.InputAssembler(vb.buffer, buffer);
|
||||
}
|
||||
else {
|
||||
ib.data = data;
|
||||
ib.dirty = true
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Clear the buffer data.
|
||||
* !#zh
|
||||
* 清除网格创建的内存数据。
|
||||
* @method clear
|
||||
*/
|
||||
clear () {
|
||||
this._subMeshes.length = 0;
|
||||
|
||||
let ibs = this._ibs;
|
||||
for (let i = 0; i < ibs.length; i++) {
|
||||
ibs[i].buffer.destroy();
|
||||
}
|
||||
ibs.length = 0;
|
||||
|
||||
let vbs = this._vbs;
|
||||
for (let i = 0; i < vbs.length; i++) {
|
||||
vbs[i].buffer.destroy();
|
||||
}
|
||||
vbs.length = 0;
|
||||
},
|
||||
|
||||
destroy () {
|
||||
this.clear();
|
||||
},
|
||||
|
||||
_uploadData () {
|
||||
let vbs = this._vbs;
|
||||
for (let i = 0; i < vbs.length; i++) {
|
||||
let vb = vbs[i];
|
||||
|
||||
if (vb.dirty) {
|
||||
vb.buffer.update(0, vb.data);
|
||||
vb.dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
let ibs = this._ibs;
|
||||
for (let i = 0; i < ibs.length; i++) {
|
||||
let ib = ibs[i];
|
||||
|
||||
if (ib.dirty) {
|
||||
ib.buffer.update(0, ib.data);
|
||||
ib.dirty = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_initWithModel (model) {
|
||||
if (!model) return;
|
||||
this._model = model;
|
||||
this._model.initMesh(this);
|
||||
},
|
||||
|
||||
_serialize: CC_EDITOR && function () {
|
||||
return {
|
||||
modelUuid: this._modelUuid,
|
||||
meshID: this._meshID,
|
||||
}
|
||||
},
|
||||
|
||||
_deserialize (data, handle) {
|
||||
this._modelUuid = data.modelUuid;
|
||||
this._meshID = data.meshID;
|
||||
|
||||
if (this._modelUuid) {
|
||||
handle.result.push(this, '_modelSetter', this._modelUuid);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cc.Mesh = module.exports = Mesh;
|
||||
@@ -23,8 +23,8 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
const RenderComponent = require('./CCRenderComponent');
|
||||
const Mesh = require('../assets/CCMesh');
|
||||
const RenderComponent = require('../components/CCRenderComponent');
|
||||
const Mesh = require('./CCMesh');
|
||||
const renderEngine = require('../renderer/render-engine');
|
||||
const gfx = renderEngine.gfx;
|
||||
const RenderFlow = require('../renderer/render-flow');
|
||||
@@ -73,13 +73,18 @@ let MeshRenderer = cc.Class({
|
||||
this.activeMaterials();
|
||||
},
|
||||
|
||||
_createMaterial () {
|
||||
_createMaterial (subMesh) {
|
||||
let material = new renderEngine.MeshMaterial();
|
||||
material.color = cc.Color.WHITE;
|
||||
if (cc.macro.ENABLE_3D) {
|
||||
material._mainTech._passes[0].setDepth(true, true);
|
||||
}
|
||||
material.useModel = true;
|
||||
|
||||
if (subMesh._vertexBuffer._format._attr2el[gfx.ATTR_COLOR]) {
|
||||
material.useAttributeColor = true;
|
||||
}
|
||||
|
||||
return material;
|
||||
},
|
||||
|
||||
@@ -89,7 +94,7 @@ let MeshRenderer = cc.Class({
|
||||
},
|
||||
|
||||
activeMaterials (force) {
|
||||
if (!this._mesh) {
|
||||
if (!this._mesh || this._mesh.subMeshes.length === 0) {
|
||||
this.disableRender();
|
||||
return;
|
||||
}
|
||||
@@ -102,7 +107,7 @@ let MeshRenderer = cc.Class({
|
||||
|
||||
let subMeshes = this._mesh._subMeshes;
|
||||
for (let i = 0; i < subMeshes.length; i++) {
|
||||
let material = this._createMaterial();
|
||||
let material = this._createMaterial(subMeshes[i]);
|
||||
this._materials.push(material);
|
||||
}
|
||||
this._material = this._materials[0];
|
||||
@@ -0,0 +1,3 @@
|
||||
require('./CCMesh');
|
||||
require('./CCMeshRenderer');
|
||||
require('./mesh-renderer');
|
||||
+62
-8
@@ -23,10 +23,14 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
const MeshRenderer = require('../../../components/CCMeshRenderer');
|
||||
const SkinnedMeshRenderer = require('../../../3d/CCSkinnedMeshRenderer');
|
||||
const RenderFlow = require('../../render-flow');
|
||||
const vfmtPosUvColor = require('../vertex-format').vfmtPosUvColor;
|
||||
const MeshRenderer = require('./CCMeshRenderer');
|
||||
|
||||
const renderEngine = require('../renderer/render-engine');
|
||||
const IARenderData = renderEngine.IARenderData;
|
||||
const gfx = renderEngine.gfx;
|
||||
const InputAssembler = renderEngine.InputAssembler;
|
||||
|
||||
const BLACK_COLOR = cc.Color.BLACK;
|
||||
|
||||
let meshRendererAssembler = {
|
||||
useModel: true,
|
||||
@@ -36,7 +40,6 @@ let meshRendererAssembler = {
|
||||
if (!comp.mesh) return;
|
||||
let submeshes = comp.mesh._subMeshes;
|
||||
for (let i = 0; i < submeshes.length; i++) {
|
||||
let IARenderData = cc.renderer.renderEngine.IARenderData;
|
||||
let data = new IARenderData();
|
||||
data.material = comp._materials[i];
|
||||
data.ia = submeshes[i];
|
||||
@@ -44,11 +47,57 @@ let meshRendererAssembler = {
|
||||
}
|
||||
},
|
||||
|
||||
createWireFrameData (ia, oldIbData, material, renderer) {
|
||||
let data = new IARenderData();
|
||||
let m = material.clone();
|
||||
m.color = BLACK_COLOR;
|
||||
m.useTexture = false;
|
||||
if (cc.macro.ENABLE_3D) {
|
||||
m._mainTech._passes[0].setDepth(true, true);
|
||||
}
|
||||
data.material = m;
|
||||
|
||||
let indices = [];
|
||||
for (let i = 0; i < oldIbData.length; i+=3) {
|
||||
let a = oldIbData[ i + 0 ];
|
||||
let b = oldIbData[ i + 1 ];
|
||||
let c = oldIbData[ i + 2 ];
|
||||
indices.push(a, b, b, c, c, a);
|
||||
}
|
||||
|
||||
let ibData = new Uint16Array(indices);
|
||||
let ib = new gfx.IndexBuffer(
|
||||
renderer._device,
|
||||
gfx.INDEX_FMT_UINT16,
|
||||
gfx.USAGE_STATIC,
|
||||
ibData,
|
||||
ibData.length
|
||||
);
|
||||
|
||||
data.ia = new renderEngine.InputAssembler(ia._vertexBuffer, ib, gfx.PT_LINES);
|
||||
return data;
|
||||
},
|
||||
|
||||
fillBuffers (comp, renderer) {
|
||||
if (!comp.mesh) return;
|
||||
|
||||
renderer._flush();
|
||||
|
||||
let renderDatas = comp._renderDatas;
|
||||
let submeshes = comp.mesh._subMeshes;
|
||||
if (cc.macro.SHOW_MESH_WIREFRAME) {
|
||||
if (renderDatas.length === submeshes.length) {
|
||||
let ibs = comp.mesh._ibs;
|
||||
for (let i = 0; i < submeshes.length; i++) {
|
||||
let data = renderDatas[i];
|
||||
renderDatas.push( this.createWireFrameData(data.ia, ibs[i].data, data.material, renderer) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
renderDatas.length = submeshes.length;
|
||||
}
|
||||
|
||||
let tmpMaterial = renderer.material;
|
||||
|
||||
let tmpNode = renderer.node;
|
||||
@@ -56,17 +105,22 @@ let meshRendererAssembler = {
|
||||
|
||||
let textures = comp.textures;
|
||||
let materials = comp._materials;
|
||||
let renderDatas = comp._renderDatas;
|
||||
for (let i = 0; i < renderDatas.length; i++) {
|
||||
let renderData = renderDatas[i];
|
||||
let material = renderData.material;
|
||||
if (textures[i]) {
|
||||
renderData.material.texture = textures[i];
|
||||
material.texture = textures[i];
|
||||
}
|
||||
else {
|
||||
material.useTexture = false;
|
||||
}
|
||||
|
||||
renderer.material = renderData.material;
|
||||
renderer.material = material;
|
||||
renderer._flushIA(renderData);
|
||||
}
|
||||
|
||||
comp.mesh._uploadData();
|
||||
|
||||
renderer.node = tmpNode;
|
||||
renderer.material = tmpMaterial;
|
||||
}
|
||||
@@ -190,6 +190,7 @@ var MotionStreak = cc.Class({
|
||||
set (value) {
|
||||
this._color = value;
|
||||
},
|
||||
type: cc.Color,
|
||||
tooltip: CC_DEV && 'i18n:COMPONENT.motionStreak.color'
|
||||
},
|
||||
|
||||
|
||||
@@ -708,7 +708,6 @@ var ParticleSystem = cc.Class({
|
||||
ctor: function () {
|
||||
this._previewTimer = null;
|
||||
this._focused = false;
|
||||
this._willStart = false;
|
||||
this._texture = null;
|
||||
|
||||
this._simulator = new ParticleSimulator(this);
|
||||
@@ -768,20 +767,6 @@ var ParticleSystem = cc.Class({
|
||||
this._focused = true;
|
||||
if (this.preview) {
|
||||
this.resetSystem();
|
||||
|
||||
var self = this;
|
||||
this._previewTimer = setInterval(function () {
|
||||
// attemptToReplay
|
||||
if (!self._willStart && self.particleCount === 0) {
|
||||
self._willStart = true;
|
||||
setTimeout(function () {
|
||||
self._willStart = false;
|
||||
if (self.preview && self._focused && !self.active && !cc.engine.isPlaying) {
|
||||
self.resetSystem();
|
||||
}
|
||||
}, 600);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1164,7 +1149,9 @@ var ParticleSystem = cc.Class({
|
||||
|
||||
_finishedSimulation: function () {
|
||||
if (CC_EDITOR) {
|
||||
this.stopSystem();
|
||||
if (this.preview && this._focused && !this.active && !cc.engine.isPlaying) {
|
||||
this.resetSystem();
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.disableRender();
|
||||
|
||||
@@ -317,10 +317,9 @@ Simulator.prototype.step = function (dt) {
|
||||
|
||||
let particle = particles[particleIdx];
|
||||
|
||||
// life
|
||||
particle.timeToLive -= dt;
|
||||
if (particle.timeToLive > 0) {
|
||||
// life
|
||||
particle.timeToLive -= dt;
|
||||
|
||||
// Mode A: gravity, direction, tangential accel & radial accel
|
||||
if (psys.emitterMode === cc.ParticleSystem.EmitterMode.GRAVITY) {
|
||||
let tmp = _tpc, radial = _tpa, tangential = _tpb;
|
||||
|
||||
@@ -50,19 +50,19 @@ var SpriteType = cc.Enum({
|
||||
* @property {Number} SLICED
|
||||
*/
|
||||
SLICED: 1,
|
||||
/*
|
||||
/**
|
||||
* !#en The tiled type.
|
||||
* !#zh 平铺类型
|
||||
* @property {Number} TILED
|
||||
*/
|
||||
TILED: 2,
|
||||
/*
|
||||
/**
|
||||
* !#en The filled type.
|
||||
* !#zh 填充类型
|
||||
* @property {Number} FILLED
|
||||
*/
|
||||
FILLED: 3,
|
||||
/*
|
||||
/**
|
||||
* !#en The mesh type.
|
||||
* !#zh 以 Mesh 三角形组成的类型
|
||||
* @property {Number} MESH
|
||||
@@ -444,7 +444,7 @@ var Sprite = cc.Class({
|
||||
}
|
||||
|
||||
this._updateAssembler();
|
||||
this.markForUpdateRenderData(true);
|
||||
this._activateMaterial();
|
||||
|
||||
this.node.on(NodeEvent.SIZE_CHANGED, this._onNodeSizeDirty, this);
|
||||
this.node.on(NodeEvent.ANCHOR_CHANGED, this._onNodeSizeDirty, this);
|
||||
@@ -478,52 +478,50 @@ var Sprite = cc.Class({
|
||||
},
|
||||
|
||||
_activateMaterial: function () {
|
||||
if (!this.enabledInHierarchy) {
|
||||
this.disableRender();
|
||||
return;
|
||||
}
|
||||
|
||||
let spriteFrame = this._spriteFrame;
|
||||
// cannot be activated if texture not loaded yet
|
||||
if (!spriteFrame || !spriteFrame.textureLoaded()) {
|
||||
this.disableRender();
|
||||
return;
|
||||
}
|
||||
|
||||
// WebGL
|
||||
if (cc.game.renderType !== cc.game.RENDER_TYPE_CANVAS) {
|
||||
// Get material
|
||||
let texture = spriteFrame.getTexture();
|
||||
let material;
|
||||
if (this._state === State.GRAY) {
|
||||
if (!this._graySpriteMaterial) {
|
||||
this._graySpriteMaterial = new GraySpriteMaterial();
|
||||
this.node._renderFlag |= RenderFlow.FLAG_COLOR;
|
||||
}
|
||||
material = this._graySpriteMaterial;
|
||||
}
|
||||
else {
|
||||
if (!this._spriteMaterial) {
|
||||
this._spriteMaterial = new SpriteMaterial();
|
||||
this.node._renderFlag |= RenderFlow.FLAG_COLOR;
|
||||
}
|
||||
material = this._spriteMaterial;
|
||||
}
|
||||
// TODO: old texture in material have been released by loader
|
||||
if (material.texture !== texture) {
|
||||
material.texture = texture;
|
||||
this._updateMaterial(material);
|
||||
// Set texture
|
||||
if (spriteFrame && spriteFrame.textureLoaded()) {
|
||||
let texture = spriteFrame.getTexture();
|
||||
if (material.texture !== texture) {
|
||||
material.texture = texture;
|
||||
this._updateMaterial(material);
|
||||
}
|
||||
else if (material !== this._material) {
|
||||
this._updateMaterial(material);
|
||||
}
|
||||
if (this._renderData) {
|
||||
this._renderData.material = material;
|
||||
}
|
||||
|
||||
this.node._renderFlag |= RenderFlow.FLAG_COLOR;
|
||||
this.markForUpdateRenderData(true);
|
||||
this.markForRender(true);
|
||||
}
|
||||
else if (material !== this._material) {
|
||||
this._updateMaterial(material);
|
||||
}
|
||||
if (this._renderData) {
|
||||
this._renderData.material = material;
|
||||
else {
|
||||
this.disableRender();
|
||||
}
|
||||
}
|
||||
|
||||
this.markForUpdateRenderData(true);
|
||||
this.markForRender(true);
|
||||
else {
|
||||
this.markForUpdateRenderData(true);
|
||||
this.markForRender(true);
|
||||
}
|
||||
},
|
||||
|
||||
_applyAtlas: CC_EDITOR && function (spriteFrame) {
|
||||
|
||||
@@ -50,6 +50,7 @@ RenderComponentWalker.prototype = {
|
||||
let ctx = this._device._ctx;
|
||||
let cam = this._camera;
|
||||
ctx.setTransform(cam.a, cam.b, cam.c, cam.d, cam.tx, cam.ty);
|
||||
ctx.scale(1, -1);
|
||||
assembler.draw(ctx, comp);
|
||||
},
|
||||
|
||||
|
||||
@@ -79,7 +79,8 @@ module.exports = js.addon({
|
||||
let matrix = node._worldMatrix;
|
||||
let a = matrix.m00, b = matrix.m01, c = matrix.m04, d = matrix.m05,
|
||||
tx = matrix.m12, ty = matrix.m13;
|
||||
ctx.transform(a, b, c, d, tx, -ty);
|
||||
ctx.transform(a, b, c, d, tx, ty);
|
||||
ctx.scale(1, -1);
|
||||
|
||||
// TODO: handle blend function
|
||||
|
||||
|
||||
@@ -62,7 +62,8 @@ module.exports = js.addon({
|
||||
let matrix = node._worldMatrix;
|
||||
let a = matrix.m00, b = matrix.m01, c = matrix.m04, d = matrix.m05,
|
||||
tx = matrix.m12, ty = matrix.m13;
|
||||
ctx.transform(a, b, c, d, tx, -ty);
|
||||
ctx.transform(a, b, c, d, tx, ty);
|
||||
ctx.scale(1, -1);
|
||||
|
||||
// TODO: handle blend function
|
||||
|
||||
|
||||
@@ -30,12 +30,6 @@ let beforeHandler = {
|
||||
updateRenderData (comp) {},
|
||||
|
||||
draw (ctx, mask) {
|
||||
let node = mask.node;
|
||||
// Transform
|
||||
let matrix = node._worldMatrix;
|
||||
let a = matrix.m00, b = matrix.m01, c = matrix.m04, d = matrix.m05,
|
||||
tx = matrix.m12, ty = matrix.m13;
|
||||
|
||||
ctx.save();
|
||||
|
||||
// draw stencil
|
||||
|
||||
@@ -123,7 +123,8 @@ let renderer = {
|
||||
let matrix = node._worldMatrix;
|
||||
let a = matrix.m00, b = matrix.m01, c = matrix.m04, d = matrix.m05,
|
||||
tx = matrix.m12, ty = matrix.m13;
|
||||
ctx.transform(a, b, c, d, tx, -ty);
|
||||
ctx.transform(a, b, c, d, tx, ty);
|
||||
ctx.scale(1, -1);
|
||||
|
||||
// TODO: handle blend function
|
||||
|
||||
|
||||
@@ -116,7 +116,8 @@ let renderer = {
|
||||
let matrix = node._worldMatrix;
|
||||
let a = matrix.m00, b = matrix.m01, c = matrix.m04, d = matrix.m05,
|
||||
tx = matrix.m12, ty = matrix.m13;
|
||||
ctx.transform(a, b, c, d, tx, -ty);
|
||||
ctx.transform(a, b, c, d, tx, ty);
|
||||
ctx.scale(1, -1);
|
||||
|
||||
// TODO: handle blend function
|
||||
|
||||
|
||||
@@ -44,7 +44,8 @@ let renderer = {
|
||||
let matrix = node._worldMatrix;
|
||||
let a = matrix.m00, b = matrix.m01, c = matrix.m04, d = matrix.m05,
|
||||
tx = matrix.m12, ty = matrix.m13;
|
||||
ctx.transform(a, b, c, d, tx, -ty);
|
||||
ctx.transform(a, b, c, d, tx, ty);
|
||||
ctx.scale(1, -1);
|
||||
|
||||
// TODO: handle blend function
|
||||
|
||||
|
||||
@@ -13658,7 +13658,7 @@ var ForwardRenderer = (function (superclass) {
|
||||
}(renderer.Base));
|
||||
|
||||
var chunks = {
|
||||
'skinning.vert': '\nattribute vec4 a_weights;\nattribute vec4 a_joints;\n#ifdef useJointsTexture\nuniform sampler2D u_jointsTexture;\nuniform float u_jointsTextureSize;\nmat4 getBoneMatrix(const in float i) {\n float size = u_jointsTextureSize;\n float j = i * 4.0;\n float x = mod(j, size);\n float y = floor(j / size);\n float dx = 1.0 / size;\n float dy = 1.0 / size;\n y = dy * (y + 0.5);\n vec4 v1 = texture2D(u_jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture2D(u_jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture2D(u_jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture2D(u_jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n}\n#else\nuniform mat4 u_jointMatrices[128];\nmat4 getBoneMatrix(const in float i) {\n return u_jointMatrices[int(i)];\n}\n#endif\nmat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n}',
|
||||
'skinning.vert': '\nattribute vec4 a_weights;\nattribute vec4 a_joints;\n#ifdef useJointsTexture\nuniform sampler2D u_jointsTexture;\nuniform float u_jointsTextureSize;\nmat4 getBoneMatrix(const in float i) {\n float size = u_jointsTextureSize;\n float j = i * 4.0;\n float x = mod(j, size);\n float y = floor(j / size);\n float dx = 1.0 / size;\n float dy = 1.0 / size;\n y = dy * (y + 0.5);\n vec4 v1 = texture2D(u_jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture2D(u_jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture2D(u_jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture2D(u_jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n}\n#else\nuniform mat4 u_jointMatrices[64];\nmat4 getBoneMatrix(const in float i) {\n return u_jointMatrices[int(i)];\n}\n#endif\nmat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n}',
|
||||
};
|
||||
|
||||
var templates = [
|
||||
@@ -13671,13 +13671,14 @@ var templates = [
|
||||
},
|
||||
{
|
||||
name: 'mesh',
|
||||
vert: '\n \nuniform mat4 viewProj;\nattribute vec3 a_position;\nattribute vec2 a_uv0;\nvarying vec2 uv0;\n#ifdef useModel\n uniform mat4 model;\n#endif\n#ifdef useSkinning\n \nattribute vec4 a_weights;\nattribute vec4 a_joints;\n#ifdef useJointsTexture\nuniform sampler2D u_jointsTexture;\nuniform float u_jointsTextureSize;\nmat4 getBoneMatrix(const in float i) {\n float size = u_jointsTextureSize;\n float j = i * 4.0;\n float x = mod(j, size);\n float y = floor(j / size);\n float dx = 1.0 / size;\n float dy = 1.0 / size;\n y = dy * (y + 0.5);\n vec4 v1 = texture2D(u_jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture2D(u_jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture2D(u_jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture2D(u_jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n}\n#else\nuniform mat4 u_jointMatrices[128];\nmat4 getBoneMatrix(const in float i) {\n return u_jointMatrices[int(i)];\n}\n#endif\nmat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n}\n#endif\nvoid main () {\n mat4 mvp;\n #ifdef useModel\n mvp = viewProj * model;\n #else\n mvp = viewProj;\n #endif\n #ifdef useSkinning\n mvp = mvp * skinMatrix();\n #endif\n vec4 pos = mvp * vec4(a_position, 1);\n uv0 = a_uv0;\n gl_Position = pos;\n}',
|
||||
frag: '\n \nuniform sampler2D texture;\nvarying vec2 uv0;\nuniform vec4 color;\nvoid main () {\n vec4 o = color;\n o *= texture2D(texture, uv0);\n gl_FragColor = o;\n}',
|
||||
vert: '\n \nuniform mat4 viewProj;\nattribute vec3 a_position;\n#ifdef useAttributeColor\n attribute vec4 a_color;\n varying vec4 v_color;\n#endif\n#ifdef useTexture\n attribute vec2 a_uv0;\n varying vec2 uv0;\n#endif\n#ifdef useModel\n uniform mat4 model;\n#endif\n#ifdef useSkinning\n \nattribute vec4 a_weights;\nattribute vec4 a_joints;\n#ifdef useJointsTexture\nuniform sampler2D u_jointsTexture;\nuniform float u_jointsTextureSize;\nmat4 getBoneMatrix(const in float i) {\n float size = u_jointsTextureSize;\n float j = i * 4.0;\n float x = mod(j, size);\n float y = floor(j / size);\n float dx = 1.0 / size;\n float dy = 1.0 / size;\n y = dy * (y + 0.5);\n vec4 v1 = texture2D(u_jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture2D(u_jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture2D(u_jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture2D(u_jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n}\n#else\nuniform mat4 u_jointMatrices[64];\nmat4 getBoneMatrix(const in float i) {\n return u_jointMatrices[int(i)];\n}\n#endif\nmat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n}\n#endif\nvoid main () {\n mat4 mvp;\n #ifdef useModel\n mvp = viewProj * model;\n #else\n mvp = viewProj;\n #endif\n #ifdef useSkinning\n mvp = mvp * skinMatrix();\n #endif\n vec4 pos = mvp * vec4(a_position, 1);\n #ifdef useTexture\n uv0 = a_uv0;\n #endif\n #ifdef useAttributeColor\n v_color = a_color;\n #endif\n gl_Position = pos;\n}',
|
||||
frag: '\n \n#ifdef useTexture\n uniform sampler2D texture;\n varying vec2 uv0;\n#endif\n#ifdef useAttributeColor\n varying vec4 v_color;\n#endif\nuniform vec4 color;\nvoid main () {\n vec4 o = color;\n \n #ifdef useAttributeColor\n o *= v_color;\n #endif\n #ifdef useTexture\n o *= texture2D(texture, uv0);\n #endif\n gl_FragColor = o;\n}',
|
||||
defines: [
|
||||
{ name: 'useTexture', },
|
||||
{ name: 'useModel', },
|
||||
{ name: 'useSkinning', },
|
||||
{ name: 'useJointsTexture', } ],
|
||||
{ name: 'useJointsTexture', },
|
||||
{ name: 'useAttributeColor', } ],
|
||||
},
|
||||
{
|
||||
name: 'sprite',
|
||||
@@ -14147,7 +14148,7 @@ var SpriteMaterial = (function (Material$$1) {
|
||||
prototypeAccessors.useTexture.set = function (val) {
|
||||
this._effect.define('useTexture', val);
|
||||
};
|
||||
|
||||
|
||||
prototypeAccessors.useModel.get = function () {
|
||||
return this._effect.getDefine('useModel');
|
||||
};
|
||||
@@ -14453,12 +14454,13 @@ var MeshMaterial = (function (Material$$1) {
|
||||
'color': {r: 1, g: 1, b: 1, a: 1}
|
||||
},
|
||||
[
|
||||
{ name: 'useTexture', value: true },
|
||||
{ name: 'useModel', value: false },
|
||||
{ name: 'useSkinning', value: false },
|
||||
{ name: 'useJointsTexture', valu: true},
|
||||
{ name: 'alphaTest', value: false } ]
|
||||
{ name: 'useAttributeColor', valu: false} ]
|
||||
);
|
||||
|
||||
|
||||
this._mainTech = mainTech;
|
||||
this._texture = null;
|
||||
this._jointsTexture = null;
|
||||
@@ -14471,12 +14473,12 @@ var MeshMaterial = (function (Material$$1) {
|
||||
MeshMaterial.prototype = Object.create( Material$$1 && Material$$1.prototype );
|
||||
MeshMaterial.prototype.constructor = MeshMaterial;
|
||||
|
||||
var prototypeAccessors = { effect: { configurable: true },useModel: { configurable: true },useSkinning: { configurable: true },useJointsTexture: { configurable: true },texture: { configurable: true },jointMatrices: { configurable: true },jointsTexture: { configurable: true },jointsTextureSize: { configurable: true },color: { configurable: true } };
|
||||
var prototypeAccessors = { effect: { configurable: true },useModel: { configurable: true },useTexture: { configurable: true },useSkinning: { configurable: true },useJointsTexture: { configurable: true },useAttributeColor: { configurable: true },texture: { configurable: true },jointMatrices: { configurable: true },jointsTexture: { configurable: true },jointsTextureSize: { configurable: true },color: { configurable: true } };
|
||||
|
||||
prototypeAccessors.effect.get = function () {
|
||||
return this._effect;
|
||||
};
|
||||
|
||||
|
||||
prototypeAccessors.useModel.get = function () {
|
||||
return this._effect.getDefine('useModel');
|
||||
};
|
||||
@@ -14485,6 +14487,14 @@ var MeshMaterial = (function (Material$$1) {
|
||||
this._effect.define('useModel', val);
|
||||
};
|
||||
|
||||
prototypeAccessors.useTexture.get = function () {
|
||||
return this._effect.getDefine('useTexture');
|
||||
};
|
||||
|
||||
prototypeAccessors.useTexture.set = function (val) {
|
||||
this._effect.define('useTexture', val);
|
||||
};
|
||||
|
||||
prototypeAccessors.useSkinning.get = function () {
|
||||
return this._effect.getDefine('useSkinning');
|
||||
};
|
||||
@@ -14501,6 +14511,14 @@ var MeshMaterial = (function (Material$$1) {
|
||||
this._effect.define('useJointsTexture', val);
|
||||
};
|
||||
|
||||
prototypeAccessors.useAttributeColor.get = function () {
|
||||
return this._effect.getDefine('useAttributeColor');
|
||||
};
|
||||
|
||||
prototypeAccessors.useAttributeColor.set = function (val) {
|
||||
this._effect.define('useAttributeColor', val);
|
||||
};
|
||||
|
||||
prototypeAccessors.texture.get = function () {
|
||||
return this._texture;
|
||||
};
|
||||
@@ -14561,10 +14579,14 @@ var MeshMaterial = (function (Material$$1) {
|
||||
MeshMaterial.prototype.clone = function clone () {
|
||||
var copy = new MeshMaterial();
|
||||
copy.texture = this.texture;
|
||||
copy.jointsTexture = this.jointsTexture;
|
||||
copy.jointsTextureSize = this.jointsTextureSize;
|
||||
copy.useTexture = this.useTexture;
|
||||
copy.color = this.color;
|
||||
copy.useModel = this.useModel;
|
||||
copu.useSkinning = this.useSkinning;
|
||||
copu.useJointsTexture = this.useJointsTexture;
|
||||
copy.useSkinning = this.useSkinning;
|
||||
copy.useJointsTexture = this.useJointsTexture;
|
||||
copy.useAttributeColor = this.useAttributeColor;
|
||||
copy.updateHash();
|
||||
return copy;
|
||||
};
|
||||
@@ -14574,8 +14596,8 @@ var MeshMaterial = (function (Material$$1) {
|
||||
return MeshMaterial;
|
||||
}(Material));
|
||||
|
||||
// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
var Device$2 = function Device(canvasEL) {
|
||||
var ctx;
|
||||
|
||||
|
||||
@@ -28,4 +28,3 @@ require('./mask-assembler');
|
||||
require('./graphics');
|
||||
require('./label');
|
||||
require('./motion-streak');
|
||||
require('./mesh-renderer');
|
||||
|
||||
@@ -35,6 +35,7 @@ const graphicsAssembler = require('./graphics');
|
||||
let _stencilMgr = StencilManager.sharedManager;
|
||||
// for nested mask, we might need multiple graphics component to avoid data conflict
|
||||
let _graphicsPool = [];
|
||||
let _graphicsUsing = [];
|
||||
|
||||
function getGraphics () {
|
||||
let graphics = _graphicsPool.pop();
|
||||
@@ -117,9 +118,17 @@ let maskEndAssembler = {
|
||||
if (mask._type !== Mask.Type.IMAGE_STENCIL || mask.spriteFrame) {
|
||||
// HACK: Must pop mask after batch, so we can only put this logic in fillBuffers
|
||||
_stencilMgr.exitMask();
|
||||
|
||||
_graphicsPool.push(mask._clearGraphics);
|
||||
|
||||
_graphicsUsing.push(mask._clearGraphics);
|
||||
mask._clearGraphics = null;
|
||||
|
||||
// Clear graphics can only be recycled after the mask stack exits entirely.
|
||||
if (_stencilMgr.stage === StencilManager.Stage.DISABLED) {
|
||||
for (let i = 0; i < _graphicsUsing.length; i++) {
|
||||
_graphicsPool.push(_graphicsUsing[i]);
|
||||
}
|
||||
_graphicsUsing.length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
mask.node._renderFlag |= RenderFlow.FLAG_UPDATE_RENDER_DATA;
|
||||
|
||||
@@ -39,7 +39,7 @@ module.exports = {
|
||||
if (!frame._original && dynamicAtlasManager) {
|
||||
dynamicAtlasManager.insertSpriteFrame(frame);
|
||||
}
|
||||
if (!sprite._material || sprite._material._texture !== frame._texture) {
|
||||
if (sprite._material._texture !== frame._texture) {
|
||||
sprite._activateMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ const dynamicAtlasManager = require('../../../utils/dynamic-atlas/manager');
|
||||
if (!frame._original && dynamicAtlasManager) {
|
||||
dynamicAtlasManager.insertSpriteFrame(frame);
|
||||
}
|
||||
if (!sprite._material || sprite._material._texture !== frame._texture) {
|
||||
if (sprite._material._texture !== frame._texture) {
|
||||
sprite._activateMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ module.exports = {
|
||||
if (!frame._original && dynamicAtlasManager) {
|
||||
dynamicAtlasManager.insertSpriteFrame(frame);
|
||||
}
|
||||
if (!sprite._material || sprite._material._texture !== frame._texture) {
|
||||
if (sprite._material._texture !== frame._texture) {
|
||||
sprite._activateMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ module.exports = {
|
||||
if (!frame._original && dynamicAtlasManager) {
|
||||
dynamicAtlasManager.insertSpriteFrame(frame);
|
||||
}
|
||||
if (!sprite._material || sprite._material._texture !== frame._texture) {
|
||||
if (sprite._material._texture !== frame._texture) {
|
||||
sprite._activateMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ module.exports = {
|
||||
if (!frame._original && dynamicAtlasManager) {
|
||||
dynamicAtlasManager.insertSpriteFrame(frame);
|
||||
}
|
||||
if (!sprite._material || sprite._material._texture !== frame._texture) {
|
||||
if (sprite._material._texture !== frame._texture) {
|
||||
sprite._activateMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ module.exports = {
|
||||
if (!frame._original && dynamicAtlasManager) {
|
||||
dynamicAtlasManager.insertSpriteFrame(frame);
|
||||
}
|
||||
if (!sprite._material || sprite._material._texture !== frame._texture) {
|
||||
if (sprite._material._texture !== frame._texture) {
|
||||
sprite._activateMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,37 +77,32 @@ StencilManager.prototype = {
|
||||
zPassOp = gfx.STENCIL_OP_KEEP;
|
||||
|
||||
if (this.stage === Stage.ENABLED) {
|
||||
func = gfx.DS_FUNC_EQUAL;
|
||||
mask = this._maskStack[this._maskStack.length - 1];
|
||||
if (mask.inverted) {
|
||||
ref = this.getInvertedRef();
|
||||
stencilMask = this.getStencilRef();
|
||||
}
|
||||
else {
|
||||
ref = this.getStencilRef();
|
||||
stencilMask = ref;
|
||||
}
|
||||
func = gfx.DS_FUNC_EQUAL;
|
||||
failOp = gfx.STENCIL_OP_KEEP;
|
||||
ref = this.getStencilRef();
|
||||
stencilMask = ref;
|
||||
writeMask = this.getWriteMask();
|
||||
}
|
||||
else {
|
||||
if (this.stage === Stage.CLEAR) {
|
||||
mask = this._maskStack[this._maskStack.length - 1];
|
||||
func = gfx.DS_FUNC_NEVER;
|
||||
failOp = mask.inverted ? gfx.STENCIL_OP_REPLACE : gfx.STENCIL_OP_ZERO;
|
||||
ref = this.getWriteMask();
|
||||
stencilMask = ref;
|
||||
writeMask = ref;
|
||||
failOp = mask.inverted ? gfx.STENCIL_OP_REPLACE : gfx.STENCIL_OP_ZERO;
|
||||
}
|
||||
else if (this.stage === Stage.ENTER_LEVEL) {
|
||||
mask = this._maskStack[this._maskStack.length - 1];
|
||||
this.stage = Stage.ENABLED;
|
||||
// Fill stencil mask
|
||||
func = gfx.DS_FUNC_NEVER;
|
||||
failOp = mask.inverted ? gfx.STENCIL_OP_ZERO : gfx.STENCIL_OP_REPLACE;
|
||||
ref = this.getWriteMask();
|
||||
stencilMask = ref;
|
||||
writeMask = ref;
|
||||
failOp = mask.inverted ? gfx.STENCIL_OP_ZERO : gfx.STENCIL_OP_REPLACE;
|
||||
|
||||
this.stage = Stage.ENABLED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -393,16 +393,19 @@ let RichText = cc.Class({
|
||||
let children = this.node.children;
|
||||
for (let i = children.length - 1; i >= 0; i--) {
|
||||
let child = children[i];
|
||||
if (child.name === RichTextChildName) {
|
||||
child.parent = null;
|
||||
pool.put(child);
|
||||
}
|
||||
else if (child.name === RichTextChildImageName) {
|
||||
child.parent = null;
|
||||
if (child.name === RichTextChildName || child.name === RichTextChildImageName) {
|
||||
if (child.parent === this.node) {
|
||||
child.parent = null;
|
||||
}
|
||||
else {
|
||||
// In case child.parent !== this.node, child cannot be removed from children
|
||||
children.splice(i, 1);
|
||||
}
|
||||
if (child.name === RichTextChildName) {
|
||||
pool.put(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
// HACK: Tolerate null parent child (upgrade issue may cause this special case)
|
||||
children.length = 0;
|
||||
|
||||
this._labelSegments.length = 0;
|
||||
this._labelSegmentsCache.length = 0;
|
||||
|
||||
@@ -639,9 +639,8 @@ let EditBox = cc.Class({
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en Let the EditBox get focus, only valid when stayOnTop is true.
|
||||
* !#zh 让当前 EditBox 获得焦点,只有在 stayOnTop 为 true 的时候设置有效
|
||||
* Note: only available on Web at the moment.
|
||||
* !#en Let the EditBox get focus
|
||||
* !#zh 让当前 EditBox 获得焦点
|
||||
* @method setFocus
|
||||
*/
|
||||
setFocus () {
|
||||
|
||||
@@ -45,6 +45,8 @@ let _matrix = math.mat4.create();
|
||||
let _matrix_temp = math.mat4.create();
|
||||
let _vec3 = cc.v3();
|
||||
|
||||
let _currentEditBoxImpl = null;
|
||||
|
||||
// polyfill
|
||||
let polyfill = {
|
||||
zoomInvalid: false
|
||||
@@ -120,9 +122,7 @@ let EditBoxImpl = cc.Class({
|
||||
},
|
||||
|
||||
setFocus () {
|
||||
if (this._edTxt) {
|
||||
this._edTxt.focus();
|
||||
}
|
||||
this._beginEditing();
|
||||
},
|
||||
|
||||
isFocused() {
|
||||
@@ -134,7 +134,7 @@ let EditBoxImpl = cc.Class({
|
||||
},
|
||||
|
||||
stayOnTop (flag) {
|
||||
if(this._alwaysOnTop === flag) return;
|
||||
if(this._alwaysOnTop === flag || !this._edTxt) return;
|
||||
|
||||
this._alwaysOnTop = flag;
|
||||
|
||||
@@ -153,13 +153,13 @@ let EditBoxImpl = cc.Class({
|
||||
maxLength = 65535;
|
||||
}
|
||||
this._maxLength = maxLength;
|
||||
this._edTxt.maxLength = maxLength;
|
||||
this._edTxt && (this._edTxt.maxLength = maxLength);
|
||||
}
|
||||
},
|
||||
|
||||
setString (text) {
|
||||
this._text = text;
|
||||
this._edTxt.value = text;
|
||||
this._edTxt && (this._edTxt.value = text);
|
||||
},
|
||||
|
||||
getString () {
|
||||
@@ -216,12 +216,12 @@ let EditBoxImpl = cc.Class({
|
||||
|
||||
setFontSize (fontSize) {
|
||||
this._edFontSize = fontSize || this._edFontSize;
|
||||
this._edTxt.style.fontSize = this._edFontSize + 'px';
|
||||
this._edTxt && (this._edTxt.style.fontSize = this._edFontSize + 'px');
|
||||
},
|
||||
|
||||
setFontColor (color) {
|
||||
this._textColor = color;
|
||||
this._edTxt.style.color = color.toCSS('rgba');
|
||||
this._edTxt && (this._edTxt.style.color = color.toCSS('rgba'));
|
||||
},
|
||||
|
||||
setSize (width, height) {
|
||||
@@ -256,31 +256,30 @@ let EditBoxImpl = cc.Class({
|
||||
},
|
||||
|
||||
_beginEditing () {
|
||||
if (!this._alwaysOnTop) {
|
||||
if (this._edTxt.style.display === 'none') {
|
||||
this._edTxt.style.display = '';
|
||||
|
||||
let self = this;
|
||||
function startFocus () {
|
||||
self._edTxt.focus();
|
||||
}
|
||||
|
||||
if (cc.sys.browserType === cc.sys.BROWSER_TYPE_UC) {
|
||||
setTimeout(startFocus, FOCUS_DELAY_UC);
|
||||
}
|
||||
else if (cc.sys.browserType === cc.sys.BROWSER_TYPE_FIREFOX) {
|
||||
setTimeout(startFocus, FOCUS_DELAY_FIREFOX);
|
||||
}
|
||||
else {
|
||||
startFocus();
|
||||
}
|
||||
if (cc.sys.isMobile && !this._editing) {
|
||||
// Pre adaptation
|
||||
this._beginEditingOnMobile();
|
||||
}
|
||||
|
||||
if (this._edTxt) {
|
||||
this._edTxt.style.display = '';
|
||||
|
||||
let self = this;
|
||||
function startFocus () {
|
||||
self._edTxt.focus();
|
||||
}
|
||||
|
||||
if (cc.sys.browserType === cc.sys.BROWSER_TYPE_UC) {
|
||||
setTimeout(startFocus, FOCUS_DELAY_UC);
|
||||
}
|
||||
else if (cc.sys.browserType === cc.sys.BROWSER_TYPE_FIREFOX) {
|
||||
setTimeout(startFocus, FOCUS_DELAY_FIREFOX);
|
||||
}
|
||||
else {
|
||||
startFocus();
|
||||
}
|
||||
}
|
||||
|
||||
if (cc.sys.isMobile && !this._editing) {
|
||||
// Pre adaptation and
|
||||
this._beginEditingOnMobile();
|
||||
}
|
||||
this._editing = true;
|
||||
},
|
||||
|
||||
@@ -312,6 +311,7 @@ let EditBoxImpl = cc.Class({
|
||||
_updateDomInputType () {
|
||||
let inputMode = this._inputMode;
|
||||
let edTxt = this._edTxt;
|
||||
if (!edTxt) return;
|
||||
|
||||
if (this._inputFlag === InputFlag.PASSWORD) {
|
||||
edTxt.type = 'password';
|
||||
@@ -447,6 +447,7 @@ _p._beginEditingOnMobile = function () {
|
||||
}
|
||||
this.__autoResize = cc.view._resizeWithBrowserSize;
|
||||
cc.view.resizeWithBrowserSize(false);
|
||||
_currentEditBoxImpl = this;
|
||||
};
|
||||
|
||||
// Called after keyboard disappeared to readapte the game view
|
||||
@@ -466,11 +467,15 @@ _p._endEditingOnMobile = function () {
|
||||
|
||||
window.removeEventListener('orientationchange', this.__orientationChanged);
|
||||
|
||||
window.scrollTo && window.scrollTo(0, 0);
|
||||
if(this.__fullscreen) {
|
||||
cc.view.enableAutoFullScreen(true);
|
||||
}
|
||||
if (this.__autoResize) {
|
||||
|
||||
// In case focus on editBox A from editBox B
|
||||
// A disable resizeWithBrowserSize
|
||||
// whilte B enable resizeWithBrowserSize
|
||||
// Only _currentEditBoxImpl can enable resizeWithBrowserSize
|
||||
if (this.__autoResize && _currentEditBoxImpl === this) {
|
||||
cc.view.resizeWithBrowserSize(true);
|
||||
}
|
||||
};
|
||||
@@ -518,7 +523,7 @@ function registerInputEventListener (tmpEdTxt, editBoxImpl, isTextarea) {
|
||||
}
|
||||
|
||||
if (cc.sys.isMobile) {
|
||||
editBoxImpl._onFocusOnMobile();
|
||||
editBoxImpl._beginEditingOnMobile();
|
||||
}
|
||||
|
||||
if (editBoxImpl._delegate && editBoxImpl._delegate.editBoxEditingDidBegan) {
|
||||
@@ -553,24 +558,6 @@ function registerInputEventListener (tmpEdTxt, editBoxImpl, isTextarea) {
|
||||
editBoxImpl._addDomToGameContainer();
|
||||
}
|
||||
|
||||
// Called after editbox focus to readapte the game view
|
||||
_p._onFocusOnMobile = function (editBox) {
|
||||
if (cc.view._isRotated) {
|
||||
cc.game.container.style['-webkit-transform'] = 'rotate(0deg)';
|
||||
cc.game.container.style.transform = 'rotate(0deg)';
|
||||
cc.view._isRotated = false;
|
||||
let policy = cc.view.getResolutionPolicy();
|
||||
policy.apply(cc.view, cc.view.getDesignResolutionSize());
|
||||
cc.view._isRotated = true;
|
||||
//use window scrollTo to adjust the input area
|
||||
window.scrollTo(35, 35);
|
||||
this.__rotateScreen = true;
|
||||
} else {
|
||||
this.__rotateScreen = false;
|
||||
}
|
||||
this._adjustEditBoxPosition();
|
||||
};
|
||||
|
||||
_p._createDomInput = function () {
|
||||
this.removeDom();
|
||||
|
||||
|
||||
@@ -30,6 +30,18 @@ const math = renderEngine.math;
|
||||
|
||||
let _mat4_temp = math.mat4.create();
|
||||
|
||||
// ios brower need to wait until the video's loadedmetadata event
|
||||
// has been fired before calling webkitEnterFullScreen()
|
||||
function triggerFullScene (video, enable) {
|
||||
if (!video) return;
|
||||
if (enable) {
|
||||
video.webkitEnterFullscreen && video.webkitEnterFullscreen();
|
||||
}
|
||||
else {
|
||||
video.webkitExitFullscreen && video.webkitExitFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
let VideoPlayerImpl = cc.Class({
|
||||
name: 'VideoPlayerImpl',
|
||||
|
||||
@@ -40,6 +52,9 @@ let VideoPlayerImpl = cc.Class({
|
||||
this._video = null;
|
||||
this._url = '';
|
||||
|
||||
this._fullScreenEnabled = false;
|
||||
|
||||
this._loadedmeta = false;
|
||||
this._loaded = false;
|
||||
this._visible = false;
|
||||
// 有一些浏览器第一次播放视频需要特殊处理,这个标记用来标识是否播放过
|
||||
@@ -66,6 +81,10 @@ let VideoPlayerImpl = cc.Class({
|
||||
//binding event
|
||||
let cbs = this.__eventListeners;
|
||||
cbs.loadedmetadata = function () {
|
||||
this._loadedmeta = true;
|
||||
if (sys.os === sys.OS_IOS && sys.isBrowser) {
|
||||
triggerFullScene(video, self._fullScreenEnabled);
|
||||
}
|
||||
self._dispatchEvent(VideoPlayerImpl.EventType.META_LOADED);
|
||||
};
|
||||
cbs.ended = function () {
|
||||
@@ -205,6 +224,7 @@ let VideoPlayerImpl = cc.Class({
|
||||
this._loaded = false;
|
||||
this._played = false;
|
||||
this._playing = false;
|
||||
this._loadedmeta = false;
|
||||
|
||||
source = document.createElement("source");
|
||||
source.src = path;
|
||||
@@ -344,15 +364,14 @@ let VideoPlayerImpl = cc.Class({
|
||||
},
|
||||
|
||||
setFullScreenEnabled: function (enable) {
|
||||
let video = this._video;
|
||||
if (!video) return;
|
||||
|
||||
let video = this._video;
|
||||
if (!video) {
|
||||
return;
|
||||
}
|
||||
if (sys.os === sys.OS_IOS && sys.isBrowser) {
|
||||
if (enable) {
|
||||
video.webkitEnterFullscreen && video.webkitEnterFullscreen();
|
||||
}
|
||||
else {
|
||||
video.webkitExitFullscreen && video.webkitExitFullscreen();
|
||||
this._fullScreenEnabled = enable;
|
||||
if (this._loadedmeta) {
|
||||
triggerFullScene(video, enable);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -363,11 +382,10 @@ let VideoPlayerImpl = cc.Class({
|
||||
cc.screen.exitFullScreen(video);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
isFullScreenEnabled: function () {
|
||||
cc.logID(7701);
|
||||
return this._fullScreenEnabled;
|
||||
},
|
||||
|
||||
setEventListener: function (event, callback) {
|
||||
|
||||
@@ -255,7 +255,7 @@ function initClipData (root, state) {
|
||||
function createPropCurve (target, propPath, keyframes) {
|
||||
var isMotionPathProp = (target instanceof cc.Node)
|
||||
&& (propPath === 'position')
|
||||
&& Array.isArray(keyframes[0].value);
|
||||
&& (keyframes[0] && Array.isArray(keyframes[0].value));
|
||||
var motionPaths = [];
|
||||
|
||||
var curve = new DynamicAnimCurve();
|
||||
|
||||
@@ -33,6 +33,11 @@ import _decorator from '../core/data/class-decorator';
|
||||
const {ccclass, property} = _decorator;
|
||||
|
||||
|
||||
const INSET_LEFT = 0;
|
||||
const INSET_TOP = 1;
|
||||
const INSET_RIGHT = 2;
|
||||
const INSET_BOTTOM = 3;
|
||||
|
||||
let temp_uvs = [{u: 0, v: 0}, {u: 0, v: 0}, {u: 0, v: 0}, {u: 0, v: 0}];
|
||||
|
||||
/**
|
||||
@@ -88,6 +93,74 @@ export default class SpriteFrame extends Asset {
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* !#en Top border of the sprite
|
||||
* !#zh sprite 的顶部边框
|
||||
* @property insetTop
|
||||
* @type {Number}
|
||||
* @default 0
|
||||
*/
|
||||
get insetTop () {
|
||||
return this._capInsets[INSET_TOP];
|
||||
}
|
||||
set insetTop (value) {
|
||||
this._capInsets[INSET_TOP] = value;
|
||||
if (this._texture) {
|
||||
this._calculateSlicedUV();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en Bottom border of the sprite
|
||||
* !#zh sprite 的底部边框
|
||||
* @property insetBottom
|
||||
* @type {Number}
|
||||
* @default 0
|
||||
*/
|
||||
get insetBottom () {
|
||||
return this._capInsets[INSET_BOTTOM];
|
||||
}
|
||||
set insetBottom (value) {
|
||||
this._capInsets[INSET_BOTTOM] = value;
|
||||
if (this._texture) {
|
||||
this._calculateSlicedUV();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en Left border of the sprite
|
||||
* !#zh sprite 的左边边框
|
||||
* @property insetLeft
|
||||
* @type {Number}
|
||||
* @default 0
|
||||
*/
|
||||
get insetLeft () {
|
||||
return this._capInsets[INSET_LEFT];
|
||||
}
|
||||
set insetLeft (value) {
|
||||
this._capInsets[INSET_LEFT] = value;
|
||||
if (this._texture) {
|
||||
this._calculateSlicedUV();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en Right border of the sprite
|
||||
* !#zh sprite 的左边边框
|
||||
* @property insetRight
|
||||
* @type {Number}
|
||||
* @default 0
|
||||
*/
|
||||
get insetRight () {
|
||||
return this._capInsets[INSET_RIGHT];
|
||||
}
|
||||
set insetRight (value) {
|
||||
this._capInsets[INSET_RIGHT] = value;
|
||||
if (this._texture) {
|
||||
this._calculateSlicedUV();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Constructor of SpriteFrame class.
|
||||
@@ -122,44 +195,10 @@ export default class SpriteFrame extends Asset {
|
||||
|
||||
this._rotated = false;
|
||||
|
||||
/**
|
||||
* !#en Top border of the sprite
|
||||
* !#zh sprite 的顶部边框
|
||||
* @property insetTop
|
||||
* @type {Number}
|
||||
* @default 0
|
||||
*/
|
||||
this.insetTop = 0;
|
||||
|
||||
/**
|
||||
* !#en Bottom border of the sprite
|
||||
* !#zh sprite 的底部边框
|
||||
* @property insetBottom
|
||||
* @type {Number}
|
||||
* @default 0
|
||||
*/
|
||||
this.insetBottom = 0;
|
||||
|
||||
/**
|
||||
* !#en Left border of the sprite
|
||||
* !#zh sprite 的左边边框
|
||||
* @property insetLeft
|
||||
* @type {Number}
|
||||
* @default 0
|
||||
*/
|
||||
this.insetLeft = 0;
|
||||
|
||||
/**
|
||||
* !#en Right border of the sprite
|
||||
* !#zh sprite 的左边边框
|
||||
* @property insetRight
|
||||
* @type {Number}
|
||||
* @default 0
|
||||
*/
|
||||
this.insetRight = 0;
|
||||
|
||||
this.vertices = null;
|
||||
|
||||
this._capInsets = [0, 0, 0, 0];
|
||||
|
||||
this.uv = [];
|
||||
this.uvSliced = [];
|
||||
|
||||
@@ -478,11 +517,11 @@ export default class SpriteFrame extends Asset {
|
||||
let rect = this._rect;
|
||||
let atlasWidth = this._texture.width;
|
||||
let atlasHeight = this._texture.height;
|
||||
let leftWidth = this.insetLeft;
|
||||
let rightWidth = this.insetRight;
|
||||
let leftWidth = this._capInsets[INSET_LEFT];
|
||||
let rightWidth = this._capInsets[INSET_RIGHT];
|
||||
let centerWidth = rect.width - leftWidth - rightWidth;
|
||||
let topHeight = this.insetTop;
|
||||
let bottomHeight = this.insetBottom;
|
||||
let topHeight = this._capInsets[INSET_TOP];
|
||||
let bottomHeight = this._capInsets[INSET_BOTTOM];
|
||||
let centerHeight = rect.height - topHeight - bottomHeight;
|
||||
|
||||
let uvSliced = this.uvSliced;
|
||||
@@ -600,13 +639,6 @@ export default class SpriteFrame extends Asset {
|
||||
if (uuid && exporting) {
|
||||
uuid = Editor.Utils.UuidUtils.compressUuid(uuid, true);
|
||||
}
|
||||
let capInsets;
|
||||
if (this.insetLeft !== 0 ||
|
||||
this.insetTop !== 0 ||
|
||||
this.insetRight !== 0 ||
|
||||
this.insetBottom !== 0) {
|
||||
capInsets = [this.insetLeft, this.insetTop, this.insetRight, this.insetBottom];
|
||||
}
|
||||
|
||||
let vertices;
|
||||
if (this.vertices) {
|
||||
@@ -627,7 +659,7 @@ export default class SpriteFrame extends Asset {
|
||||
offset: offset ? [offset.x, offset.y] : undefined,
|
||||
originalSize: size ? [size.width, size.height] : undefined,
|
||||
rotated: this._rotated ? 1 : undefined,
|
||||
capInsets: capInsets,
|
||||
capInsets: this._capInsets,
|
||||
vertices: vertices
|
||||
};
|
||||
}
|
||||
@@ -645,13 +677,15 @@ export default class SpriteFrame extends Asset {
|
||||
}
|
||||
this._rotated = data.rotated === 1;
|
||||
this._name = data.name;
|
||||
|
||||
let capInsets = data.capInsets;
|
||||
if (capInsets) {
|
||||
this.insetLeft = capInsets[0];
|
||||
this.insetTop = capInsets[1];
|
||||
this.insetRight = capInsets[2];
|
||||
this.insetBottom = capInsets[3];
|
||||
this._capInsets[INSET_LEFT] = capInsets[INSET_LEFT];
|
||||
this._capInsets[INSET_TOP] = capInsets[INSET_TOP];
|
||||
this._capInsets[INSET_RIGHT] = capInsets[INSET_RIGHT];
|
||||
this._capInsets[INSET_BOTTOM] = capInsets[INSET_BOTTOM];
|
||||
}
|
||||
|
||||
if (CC_EDITOR) {
|
||||
this._atlasUuid = data.atlas;
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ export default class Camera extends Component {
|
||||
_cullingMask = 0xffffffff;
|
||||
|
||||
@property
|
||||
_clearFlags = 0;
|
||||
_clearFlags = ClearFlags.DEPTH | ClearFlags.STENCIL;
|
||||
|
||||
@property
|
||||
_backgroundColor = cc.color(0, 0, 0, 255);
|
||||
|
||||
@@ -69,6 +69,7 @@ export default class Canvas extends Component {
|
||||
this._designResolution.width = value.width;
|
||||
this._designResolution.height = value.height;
|
||||
this.applySettings();
|
||||
this.alignWithScreen();
|
||||
}
|
||||
|
||||
@property
|
||||
@@ -92,6 +93,7 @@ export default class Canvas extends Component {
|
||||
if (this._fitHeight !== value) {
|
||||
this._fitHeight = value;
|
||||
this.applySettings();
|
||||
this.alignWithScreen();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,14 +113,10 @@ export default class Canvas extends Component {
|
||||
if (this._fitWidth !== value) {
|
||||
this._fitWidth = value;
|
||||
this.applySettings();
|
||||
this.alignWithScreen();
|
||||
}
|
||||
}
|
||||
|
||||
constructor () {
|
||||
super();
|
||||
this._thisOnResized = this.onResized.bind(this);
|
||||
}
|
||||
|
||||
resetInEditor () {
|
||||
_Scene._applyCanvasPreferences(this);
|
||||
}
|
||||
@@ -135,8 +133,6 @@ export default class Canvas extends Component {
|
||||
}
|
||||
Canvas.instance = this;
|
||||
|
||||
cc.director.on(cc.Director.EVENT_AFTER_UPDATE, this.alignWithScreen, this);
|
||||
|
||||
if (CC_EDITOR) {
|
||||
cc.engine.on('design-resolution-changed', this._thisOnResized);
|
||||
}
|
||||
@@ -150,7 +146,7 @@ export default class Canvas extends Component {
|
||||
}
|
||||
|
||||
this.applySettings();
|
||||
this.onResized();
|
||||
this.alignWithScreen();
|
||||
|
||||
// Camera could be removed in canvas render mode
|
||||
let cameraNode = cc.find('Main Camera', this.node);
|
||||
@@ -162,7 +158,7 @@ export default class Canvas extends Component {
|
||||
let camera = cameraNode.getComponent(Camera);
|
||||
if (!camera) {
|
||||
camera = cameraNode.addComponent(Camera);
|
||||
|
||||
|
||||
let ClearFlags = Camera.ClearFlags;
|
||||
camera.clearFlags = ClearFlags.COLOR | ClearFlags.DEPTH | ClearFlags.STENCIL;
|
||||
camera.depth = -1;
|
||||
@@ -171,8 +167,6 @@ export default class Canvas extends Component {
|
||||
}
|
||||
|
||||
onDestroy () {
|
||||
cc.director.off(cc.Director.EVENT_AFTER_UPDATE, this.alignWithScreen, this);
|
||||
|
||||
if (CC_EDITOR) {
|
||||
cc.engine.off('design-resolution-changed', this._thisOnResized);
|
||||
}
|
||||
@@ -215,11 +209,6 @@ export default class Canvas extends Component {
|
||||
this.node.height = nodeSize.height;
|
||||
}
|
||||
|
||||
onResized () {
|
||||
// TODO - size dirty
|
||||
this.alignWithScreen();
|
||||
}
|
||||
|
||||
applySettings () {
|
||||
var ResolutionPolicy = cc.ResolutionPolicy;
|
||||
var policy;
|
||||
|
||||
@@ -507,7 +507,7 @@ class Director extends EventTarget {
|
||||
if (!key.endsWith('.fire')) {
|
||||
key += '.fire';
|
||||
}
|
||||
if (key[0] !== '/' && !key.startsWith('db://assets/')) {
|
||||
if (key[0] !== '/' && !key.startsWith('db://')) {
|
||||
key = '/' + key; // 使用全名匹配
|
||||
}
|
||||
// search scene
|
||||
|
||||
@@ -1489,6 +1489,16 @@ var macro = {
|
||||
* @default false
|
||||
*/
|
||||
CLEANUP_IMAGE_CACHE: false,
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Whether or not show mesh wire frame.
|
||||
* !#zh
|
||||
* 是否显示网格的线框。
|
||||
* @property {Boolean} SHOW_MESH_WIREFRAME
|
||||
* @default false
|
||||
*/
|
||||
SHOW_MESH_WIREFRAME: false,
|
||||
}
|
||||
|
||||
cc.macro = macro;
|
||||
|
||||
@@ -659,7 +659,6 @@ else if (CC_QQPLAY) {
|
||||
sys.isMobile = true;
|
||||
sys.platform = sys.QQ_PLAY;
|
||||
sys.language = sys.LANGUAGE_UNKNOWN;
|
||||
var system = env.system.toLowerCase();
|
||||
if (env.platform === "android") {
|
||||
sys.os = sys.OS_ANDROID;
|
||||
}
|
||||
@@ -669,14 +668,7 @@ else if (CC_QQPLAY) {
|
||||
else {
|
||||
sys.os = sys.OS_UNKNOWN;
|
||||
}
|
||||
|
||||
// Adaptation to Android P
|
||||
if (system === 'android p') {
|
||||
system = 'android p 9.0';
|
||||
}
|
||||
|
||||
var version = /[\d\.]+/.exec(system);
|
||||
sys.osVersion = version ? version[0] : system;
|
||||
sys.osVersion = env.version;
|
||||
sys.osMainVersion = parseInt(sys.osVersion.split('.')[0]);
|
||||
sys.browserType = sys.BROWSER_TYPE_QQ_PLAY;
|
||||
sys.browserVersion = 0;
|
||||
@@ -1127,9 +1119,6 @@ sys.getBatteryLevel = function() {
|
||||
*/
|
||||
sys.garbageCollect = function () {
|
||||
// N/A in web
|
||||
if (CC_JSB) {
|
||||
jsb.garbageCollect();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1138,9 +1127,6 @@ sys.garbageCollect = function () {
|
||||
*/
|
||||
sys.dumpRoot = function () {
|
||||
// N/A in web
|
||||
if (CC_JSB) {
|
||||
jsb.dumpRoot();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1149,9 +1135,6 @@ sys.dumpRoot = function () {
|
||||
*/
|
||||
sys.restartVM = function () {
|
||||
// N/A in web
|
||||
if (CC_JSB) {
|
||||
__restartVM();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1161,9 +1144,6 @@ sys.restartVM = function () {
|
||||
*/
|
||||
sys.cleanScript = function (jsfile) {
|
||||
// N/A in web
|
||||
if (CC_JSB) {
|
||||
__cleanScript(jsfile);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1175,13 +1155,9 @@ sys.cleanScript = function (jsfile) {
|
||||
* @return {Boolean} Validity of the object
|
||||
*/
|
||||
sys.isObjectValid = function (obj) {
|
||||
if (CC_JSB) {
|
||||
return __isObjectValid(obj);
|
||||
}
|
||||
else if (obj) {
|
||||
if (obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
@@ -343,6 +343,15 @@ class View extends EventTarget {
|
||||
cc.game.container.style['-webkit-transform-origin'] = '0px 0px 0px';
|
||||
cc.game.container.style.transformOrigin = '0px 0px 0px';
|
||||
this._isRotated = true;
|
||||
|
||||
// Fix for issue: https://github.com/cocos-creator/fireball/issues/8365
|
||||
// Reference: https://www.douban.com/note/343402554/
|
||||
// For Chrome, z-index not working after container transform rotate 90deg.
|
||||
// Because 'transform' style adds canvas (the top-element of container) to a new stack context.
|
||||
// That causes the DOM Input was hidden under canvas.
|
||||
// This should be done after container rotated, instead of in style-mobile.css.
|
||||
cc.game.canvas.style['-webkit-transform'] = 'translateZ(0px)';
|
||||
cc.game.canvas.style.transform = 'translateZ(0px)';
|
||||
}
|
||||
if (this._orientationChanging) {
|
||||
setTimeout(function () {
|
||||
|
||||
@@ -313,7 +313,6 @@ export function get (obj, prop, getter, enumerable, configurable) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Define set accessor, just help to call Object.defineProperty(...)
|
||||
* @method set
|
||||
|
||||
@@ -331,18 +331,25 @@ export default class BaseNode extends CCObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en The parent of the node.
|
||||
* !#zh 该节点的父节点。
|
||||
* @property parent
|
||||
* @type {Node}
|
||||
* @default null
|
||||
* !#en Get parent of the node.
|
||||
* !#zh 获取该节点的父节点。
|
||||
* @method getParent
|
||||
* @return {Node}
|
||||
* @example
|
||||
* node.parent = newNode;
|
||||
* var parent = this.node.getParent();
|
||||
*/
|
||||
getParent () {
|
||||
return this._parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en Set parent of the node.
|
||||
* !#zh 设置该节点的父节点。
|
||||
* @method setParent
|
||||
* @param {Node} value
|
||||
* @example
|
||||
* node.setParent(newNode);
|
||||
*/
|
||||
setParent (value) {
|
||||
if (this._parent === value) {
|
||||
return;
|
||||
@@ -489,7 +496,7 @@ export default class BaseNode extends CCObject {
|
||||
* !#en Get the sibling index.
|
||||
* !#zh 获取同级索引。
|
||||
* @method getSiblingIndex
|
||||
* @return {number}
|
||||
* @return {Number}
|
||||
* @example
|
||||
* var index = node.getSiblingIndex();
|
||||
*/
|
||||
|
||||
+42
-20
@@ -1253,6 +1253,19 @@ export default class Node extends BaseNode {
|
||||
|
||||
// INTERNAL
|
||||
|
||||
_syncEulerAngles () {
|
||||
let quat = this._quat;
|
||||
let rotx = quat.getRoll();
|
||||
let roty = quat.getPitch();
|
||||
if (rotx === 0 && roty === 0) {
|
||||
this._rotationX = this._rotationY = -quat.getYaw();
|
||||
}
|
||||
else {
|
||||
this._rotationX = rotx;
|
||||
this._rotationY = roty;
|
||||
}
|
||||
}
|
||||
|
||||
_upgrade_1x_to_2x () {
|
||||
// Upgrade scaleX, scaleY from v1.x
|
||||
// TODO: remove in future version, 3.0 ?
|
||||
@@ -1272,25 +1285,19 @@ export default class Node extends BaseNode {
|
||||
// TODO: remove _rotationX & _rotationY in future version, 3.0 ?
|
||||
// Update quaternion from rotation, when upgrade from 1.x to 2.0
|
||||
// If rotation x & y is 0 in old version, then update rotation from default quaternion is ok too
|
||||
if (this._rotationX !== 0 || this._rotationY !== 0) {
|
||||
let quat = this._quat;
|
||||
if ((this._rotationX !== 0 || this._rotationY !== 0) &&
|
||||
(quat.x === 0 && quat.y === 0 && quat.z === 0 && quat.w === 1)) {
|
||||
if (this._rotationX === this._rotationY) {
|
||||
math.quat.fromEuler(this._quat, 0, 0, -this._rotationX);
|
||||
math.quat.fromEuler(quat, 0, 0, -this._rotationX);
|
||||
}
|
||||
else {
|
||||
math.quat.fromEuler(this._quat, this._rotationX, this._rotationY, 0);
|
||||
math.quat.fromEuler(quat, this._rotationX, this._rotationY, 0);
|
||||
}
|
||||
}
|
||||
// Update rotation from quaternion
|
||||
else {
|
||||
let rotx = this._quat.getRoll();
|
||||
let roty = this._quat.getPitch();
|
||||
if (rotx === 0 && roty === 0) {
|
||||
this._rotationX = this._rotationY = -this._quat.getYaw();
|
||||
}
|
||||
else {
|
||||
this._rotationX = rotx;
|
||||
this._rotationY = roty;
|
||||
}
|
||||
this._syncEulerAngles();
|
||||
}
|
||||
|
||||
// Upgrade from 2.0.0 preview 4 & earlier versions
|
||||
@@ -1974,19 +1981,34 @@ export default class Node extends BaseNode {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en Set rotation of node (along z axi).
|
||||
* !#zh 设置该节点以局部坐标系 Z 轴为轴进行旋转的角度。
|
||||
* @method setRotation
|
||||
* @param {Number} rotation Degree rotation value
|
||||
*/
|
||||
|
||||
/**
|
||||
* !#en Get rotation of node (along z axi).
|
||||
* !#zh 获取该节点以局部坐标系 Z 轴为轴进行旋转的角度。
|
||||
* @method getRotation
|
||||
* @param {Number} rotation Degree rotation value
|
||||
*/
|
||||
getRotation () {
|
||||
return this._rotationX;
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en Set rotation of node (along z axi).
|
||||
* !#zh 设置该节点以局部坐标系 Z 轴为轴进行旋转的角度。
|
||||
* @method setRotation
|
||||
* @param {Number} rotation Degree rotation value
|
||||
*/
|
||||
setRotation (value) {
|
||||
if (this._rotationX !== value || this._rotationY !== value) {
|
||||
this._rotationX = this._rotationY = value;
|
||||
// Update quaternion from rotation
|
||||
math.quat.fromEuler(this._quat, 0, 0, -value);
|
||||
this.setLocalDirty(LocalDirtyFlag.ROTATION);
|
||||
|
||||
if (this._eventMask & ROTATION_ON) {
|
||||
this.emit(EventType.ROTATION_CHANGED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en
|
||||
@@ -2164,7 +2186,7 @@ export default class Node extends BaseNode {
|
||||
* Set world position.
|
||||
* This is not a public API yet, its usage could be updated
|
||||
* @method setWorldPos
|
||||
* @param {vec3} pos
|
||||
* @param {Vec3} pos
|
||||
*/
|
||||
setWorldPos (pos) {
|
||||
// NOTE: this is faster than invert world matrix and transform the point
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
@@ -23,70 +24,19 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @module cc
|
||||
*/
|
||||
/**
|
||||
* !#en Mesh Asset.
|
||||
* !#zh 网格资源。
|
||||
* @class Mesh
|
||||
* @extends Asset
|
||||
*/
|
||||
var Mesh = cc.Class({
|
||||
name: 'cc.Mesh',
|
||||
extends: cc.Asset,
|
||||
|
||||
properties: {
|
||||
_modelSetter: {
|
||||
set: function (model) {
|
||||
this.initWithModel(model);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en Get ir set the sub meshes.
|
||||
* !#zh 设置或者获取子网格。
|
||||
* @property {[renderEngine.InputAssembler]} subMeshes
|
||||
*/
|
||||
subMeshes: {
|
||||
get () {
|
||||
return this._subMeshes;
|
||||
},
|
||||
set (v) {
|
||||
this._subMeshes = v;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
ctor () {
|
||||
this._modelUuid = '';
|
||||
this._meshID = -1;
|
||||
this._model = null;
|
||||
|
||||
this._subMeshes = [];
|
||||
},
|
||||
|
||||
initWithModel (model) {
|
||||
if (!model) return;
|
||||
this._model = model;
|
||||
this._model.initMesh(this);
|
||||
},
|
||||
|
||||
_serialize: CC_EDITOR && function () {
|
||||
return {
|
||||
modelUuid: this._modelUuid,
|
||||
meshID: this._meshID,
|
||||
}
|
||||
},
|
||||
|
||||
_deserialize (data, handle) {
|
||||
this._modelUuid = data.modelUuid;
|
||||
this._meshID = data.meshID;
|
||||
|
||||
if (this._modelUuid) {
|
||||
handle.result.push(this, '_modelSetter', this._modelUuid);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cc.Mesh = module.exports = Mesh;
|
||||
require('./CCRawAsset');
|
||||
require('./CCAsset');
|
||||
require('./CCFont');
|
||||
require('./CCPrefab');
|
||||
require('./CCAudioClip');
|
||||
require('./CCScripts');
|
||||
require('./CCSceneAsset');
|
||||
require('./CCSpriteFrame');
|
||||
require('./CCTexture2D');
|
||||
require('./CCRenderTexture');
|
||||
require('./CCTTFFont');
|
||||
require('./CCSpriteAtlas');
|
||||
require('./CCBitmapFont');
|
||||
require('./CCLabelAtlas');
|
||||
require('./CCTextAsset');
|
||||
require('./CCJsonAsset');
|
||||
@@ -23,6 +23,7 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
const StencilManager = require('../../cocos2d/core/renderer/webgl/stencil-manager').sharedManager;
|
||||
const Skeleton = require('./Skeleton');
|
||||
const spine = require('./lib/spine');
|
||||
const renderer = require('../../cocos2d/core/renderer');
|
||||
@@ -32,6 +33,8 @@ const renderEngine = renderer.renderEngine;
|
||||
const gfx = renderEngine.gfx;
|
||||
const SpriteMaterial = renderEngine.SpriteMaterial;
|
||||
|
||||
const STENCIL_SEP = '@';
|
||||
|
||||
let _sharedMaterials = {};
|
||||
|
||||
let _slotColor = cc.color(0, 0, 255, 255);
|
||||
@@ -43,6 +46,10 @@ _debugMaterial.useColor = false;
|
||||
_debugMaterial.useTexture = false;
|
||||
_debugMaterial.updateHash();
|
||||
|
||||
function _updateKeyWithStencilRef (key, stencilRef) {
|
||||
return key.replace(/@\d+$/, STENCIL_SEP + stencilRef);
|
||||
}
|
||||
|
||||
function _getSlotMaterial (slot, tex, premultiAlpha) {
|
||||
let src, dst;
|
||||
switch (slot.data.blendMode) {
|
||||
@@ -64,7 +71,8 @@ function _getSlotMaterial (slot, tex, premultiAlpha) {
|
||||
dst = cc.macro.ONE_MINUS_SRC_ALPHA;
|
||||
break;
|
||||
}
|
||||
let key = tex.url + src + dst;
|
||||
|
||||
let key = tex.url + src + dst + STENCIL_SEP + '0';
|
||||
let material = _sharedMaterials[key];
|
||||
if (!material) {
|
||||
material = new SpriteMaterial();
|
||||
@@ -72,7 +80,7 @@ function _getSlotMaterial (slot, tex, premultiAlpha) {
|
||||
// update texture
|
||||
material.texture = tex;
|
||||
material.useColor = false;
|
||||
|
||||
|
||||
// update blend function
|
||||
let pass = material._mainTech.passes[0];
|
||||
pass.setBlend(
|
||||
@@ -82,11 +90,11 @@ function _getSlotMaterial (slot, tex, premultiAlpha) {
|
||||
src, dst
|
||||
);
|
||||
_sharedMaterials[key] = material;
|
||||
material.updateHash();
|
||||
material.updateHash(key);
|
||||
}
|
||||
else if (material.texture !== tex) {
|
||||
material.texture = tex;
|
||||
material.updateHash();
|
||||
material.updateHash(key);
|
||||
}
|
||||
return material;
|
||||
}
|
||||
@@ -126,7 +134,7 @@ var spineAssembler = {
|
||||
|
||||
if (comp.debugSlots && vertexCount === 4) {
|
||||
let graphics = comp._debugRenderer;
|
||||
|
||||
|
||||
// Debug Slot
|
||||
let VERTEX = spine.RegionAttachment;
|
||||
graphics.strokeColor = _slotColor;
|
||||
@@ -269,7 +277,7 @@ var spineAssembler = {
|
||||
graphics.moveTo(bone.worldX, bone.worldY);
|
||||
graphics.lineTo(x, y);
|
||||
graphics.stroke();
|
||||
|
||||
|
||||
// Bone origins.
|
||||
graphics.circle(bone.worldX, bone.worldY, Math.PI * 2);
|
||||
graphics.fill();
|
||||
@@ -296,6 +304,18 @@ var spineAssembler = {
|
||||
for (let index = 0, length = renderDatas.length; index < length; index++) {
|
||||
let data = renderDatas[index];
|
||||
|
||||
// For generate new material for skeleton render data nested in mask,
|
||||
// otherwise skeleton inside/outside mask with same material will interfere each other
|
||||
let key = data.material._hash;
|
||||
let newKey = _updateKeyWithStencilRef(key, StencilManager.getStencilRef());
|
||||
if (key !== newKey) {
|
||||
data.material = _sharedMaterials[newKey] || data.material.clone();
|
||||
data.material.updateHash(newKey);
|
||||
if (!_sharedMaterials[newKey]) {
|
||||
_sharedMaterials[newKey] = data.material;
|
||||
}
|
||||
}
|
||||
|
||||
if (data.material !== renderer.material) {
|
||||
renderer._flush();
|
||||
renderer.node = comp.node;
|
||||
|
||||
@@ -268,6 +268,13 @@
|
||||
"name": "3D",
|
||||
"entries": [
|
||||
"./cocos2d/core/3d/index.js"
|
||||
],
|
||||
"dependencies": ["Mesh", "WebGL Renderer"]
|
||||
},
|
||||
{
|
||||
"name": "Mesh",
|
||||
"entries": [
|
||||
"./cocos2d/core/mesh/index.js"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
+2
-1
@@ -152,13 +152,14 @@ defineMacro('CC_BUILD', false);
|
||||
if (CC_BUILD) {
|
||||
// Supports dynamically access from external scripts such as adapters and debugger.
|
||||
// So macros should still defined in global even if inlined in engine.
|
||||
_global.CC_BUILD = CC_BUILD;
|
||||
_global.CC_TEST = CC_TEST;
|
||||
_global.CC_EDITOR = CC_EDITOR;
|
||||
_global.CC_PREVIEW = CC_PREVIEW;
|
||||
_global.CC_DEV = CC_DEV;
|
||||
_global.CC_DEBUG = CC_DEBUG;
|
||||
_global.CC_JSB = CC_JSB;
|
||||
_global.CC_BUILD = CC_BUILD;
|
||||
_global.CC_WECHATGAME_SUB = CC_WECHATGAMESUB;
|
||||
_global.CC_WECHATGAME = CC_WECHATGAME;
|
||||
_global.CC_QQPLAY = CC_QQPLAY;
|
||||
_global.CC_RUNTIME = CC_RUNTIME;
|
||||
|
||||
Reference in New Issue
Block a user