更新效果名为点光
This commit is contained in:
parent
40e905fc81
commit
ae865a7c5f
@ -3,7 +3,7 @@
|
|||||||
// 原理:
|
// 原理:
|
||||||
// 1. 画圆
|
// 1. 画圆
|
||||||
// 2. 圆心高亮(透明度=1.0),圆边缘不亮(透明度=0.0)
|
// 2. 圆心高亮(透明度=1.0),圆边缘不亮(透明度=0.0)
|
||||||
// 4. 在原图像上方叠加圆
|
// 3. 在原图像上方叠加圆
|
||||||
|
|
||||||
CCEffect %{
|
CCEffect %{
|
||||||
techniques:
|
techniques:
|
@ -1,8 +1,8 @@
|
|||||||
const { ccclass, property } = cc._decorator;
|
const { ccclass, property } = cc._decorator;
|
||||||
|
|
||||||
@ccclass
|
@ccclass
|
||||||
export default class LocalDiffusionCtrl extends cc.Component {
|
export default class PointLightCtrlComponent extends cc.Component {
|
||||||
private _localDiffusionUniform: LocalDiffusionUniform = new LocalDiffusionUniform();
|
private _localDiffusionUniform: PointLightUniform = new PointLightUniform();
|
||||||
|
|
||||||
onEnable() {
|
onEnable() {
|
||||||
this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchStart, this);
|
this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchStart, this);
|
||||||
@ -34,7 +34,7 @@ export default class LocalDiffusionCtrl extends cc.Component {
|
|||||||
this._updateMaterial();
|
this._updateMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onPropertyChange(localDiffusionUniform: LocalDiffusionUniform) {
|
private _onPropertyChange(localDiffusionUniform: PointLightUniform) {
|
||||||
this._localDiffusionUniform.centerColor = localDiffusionUniform.centerColor;
|
this._localDiffusionUniform.centerColor = localDiffusionUniform.centerColor;
|
||||||
this._localDiffusionUniform.radius = localDiffusionUniform.radius;
|
this._localDiffusionUniform.radius = localDiffusionUniform.radius;
|
||||||
this._localDiffusionUniform.cropAlpha = localDiffusionUniform.cropAlpha;
|
this._localDiffusionUniform.cropAlpha = localDiffusionUniform.cropAlpha;
|
||||||
@ -55,7 +55,7 @@ export default class LocalDiffusionCtrl extends cc.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class LocalDiffusionUniform {
|
export class PointLightUniform {
|
||||||
/**
|
/**
|
||||||
* 中心点颜色
|
* 中心点颜色
|
||||||
*/
|
*/
|
@ -1,9 +1,9 @@
|
|||||||
import LocalDiffusionCtrl, { LocalDiffusionUniform } from "./LocalDiffusionCtrl";
|
import PointLightCtrlComponent, { PointLightUniform } from "./PointLightCtrlComponent";
|
||||||
|
|
||||||
const { ccclass, property } = cc._decorator;
|
const { ccclass, property } = cc._decorator;
|
||||||
|
|
||||||
@ccclass
|
@ccclass
|
||||||
export default class LocalDiffusionEffectScene extends cc.Component {
|
export default class PointLightEffectScene extends cc.Component {
|
||||||
private _redSlider: cc.Slider = null;
|
private _redSlider: cc.Slider = null;
|
||||||
private _redSliderLabel: cc.Label = null;
|
private _redSliderLabel: cc.Label = null;
|
||||||
private _greenSlider: cc.Slider = null;
|
private _greenSlider: cc.Slider = null;
|
||||||
@ -40,7 +40,7 @@ export default class LocalDiffusionEffectScene extends cc.Component {
|
|||||||
// 代码添加控制脚本
|
// 代码添加控制脚本
|
||||||
this._examplesParentNode = cc.find("Canvas/Content/Examples");
|
this._examplesParentNode = cc.find("Canvas/Content/Examples");
|
||||||
this._examplesParentNode.children.forEach(childNode => {
|
this._examplesParentNode.children.forEach(childNode => {
|
||||||
childNode.addComponent(LocalDiffusionCtrl);
|
childNode.addComponent(PointLightCtrlComponent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ export default class LocalDiffusionEffectScene extends cc.Component {
|
|||||||
|
|
||||||
// 通知子节点更新材质
|
// 通知子节点更新材质
|
||||||
this._examplesParentNode.children.forEach(childNode => {
|
this._examplesParentNode.children.forEach(childNode => {
|
||||||
childNode.emit("on_property_change", <LocalDiffusionUniform>{
|
childNode.emit("on_property_change", <PointLightUniform>{
|
||||||
centerColor: cc.color(
|
centerColor: cc.color(
|
||||||
Math.round(255 * this._redSlider.progress),
|
Math.round(255 * this._redSlider.progress),
|
||||||
Math.round(255 * this._greenSlider.progress),
|
Math.round(255 * this._greenSlider.progress),
|
Before Width: | Height: | Size: 3.9 MiB After Width: | Height: | Size: 3.9 MiB |
Loading…
Reference in New Issue
Block a user