From 9fca60746cd204997dee535ff0ac231eacca58e2 Mon Sep 17 00:00:00 2001 From: SmallMain Date: Sat, 25 Jun 2022 00:44:28 +0800 Subject: [PATCH] =?UTF-8?q?[jsb-adapter]=20=E5=A4=9A=E7=BA=B9=E7=90=86?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=20-=20=E9=80=82=E9=85=8D=E5=8E=9F=E7=94=9F?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jsb-adapter/builtin/renderer/enums.js | 1 + jsb-adapter/engine/assemblers/assembler.js | 6 +++++- .../engine/assemblers/motion-streak-multi.js | 21 +++++++++++++++++++ .../engine/assemblers/motion-streak.js | 2 +- jsb-adapter/engine/index.js | 1 + 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 jsb-adapter/engine/assemblers/motion-streak-multi.js diff --git a/jsb-adapter/builtin/renderer/enums.js b/jsb-adapter/builtin/renderer/enums.js index 293d3a53..2a0776b1 100644 --- a/jsb-adapter/builtin/renderer/enums.js +++ b/jsb-adapter/builtin/renderer/enums.js @@ -211,6 +211,7 @@ export const enums = { ATTR_TEX_COORD6: 'a_texCoord6', ATTR_TEX_COORD7: 'a_texCoord7', ATTR_TEX_COORD8: 'a_texCoord8', + ATTR_TEX_ID: 'a_texId', // vertex attribute type ATTR_TYPE_INT8: 5120, // gl.BYTE diff --git a/jsb-adapter/engine/assemblers/assembler.js b/jsb-adapter/engine/assemblers/assembler.js index 593e8b1b..c3bf5367 100644 --- a/jsb-adapter/engine/assemblers/assembler.js +++ b/jsb-adapter/engine/assemblers/assembler.js @@ -68,8 +68,12 @@ let Assembler = { _updateRenderData () { if (!this._renderComp || !this._renderComp.isValid) return; - this.updateRenderData(this._renderComp); + if (!this.updateRenderData(this._renderComp)) { + this._aftUpdateRenderDataForNative(); + } + }, + _aftUpdateRenderDataForNative() { let materials = this._renderComp._materials; for (let i = 0; i < materials.length; i++) { let m = materials[i]; diff --git a/jsb-adapter/engine/assemblers/motion-streak-multi.js b/jsb-adapter/engine/assemblers/motion-streak-multi.js new file mode 100644 index 00000000..1df4efc6 --- /dev/null +++ b/jsb-adapter/engine/assemblers/motion-streak-multi.js @@ -0,0 +1,21 @@ + +let proto = cc.MotionStreak.__assembler__.MultiMotionStreakAssembler.prototype; +let _update = proto.update; +cc.js.mixin(proto, { + 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; + } + } +}); diff --git a/jsb-adapter/engine/assemblers/motion-streak.js b/jsb-adapter/engine/assemblers/motion-streak.js index 84bf99e3..8ad9648a 100644 --- a/jsb-adapter/engine/assemblers/motion-streak.js +++ b/jsb-adapter/engine/assemblers/motion-streak.js @@ -1,5 +1,5 @@ -let proto = cc.MotionStreak.__assembler__.prototype; +let proto = cc.MotionStreak.__assembler__.MotionStreakAssembler.prototype; let _init = proto.init; let _update = proto.update; cc.js.mixin(proto, { diff --git a/jsb-adapter/engine/index.js b/jsb-adapter/engine/index.js index ccf31745..b507ac91 100644 --- a/jsb-adapter/engine/index.js +++ b/jsb-adapter/engine/index.js @@ -58,6 +58,7 @@ if (CC_NATIVERENDERER) { require('./assemblers/mask-assembler.js'); require('./assemblers/graphics-assembler.js'); require('./assemblers/motion-streak.js'); + require('./assemblers/motion-streak-multi.js'); require('./assemblers/mesh-renderer.js'); require('./assemblers/particle-3d-assembler.js');