Skip to content

Commit 7704145

Browse files
authored
Fixes for examples (playcanvas#3349)
* refactor animation events example code * fixes for examples
1 parent eac6471 commit 7704145

File tree

4 files changed

+7
-320
lines changed

4 files changed

+7
-320
lines changed

examples/src/examples/animation/events.tsx

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class EventsExample extends Example {
7979
const colorVec = new pc.Vec3(Math.random(), Math.random(), Math.random());
8080
colorVec.mulScalar(1 / colorVec.length());
8181
// @ts-ignore engine-tsd
82-
boxes[`${i}${j}`].model.material.emissive = new pc.Color(colorVec.data);
82+
boxes[`${i}${j}`].model.material.emissive = new pc.Color(colorVec.x, colorVec.y, colorVec.z);
8383
highlightedBoxes.push(boxes[`${i}${j}`]);
8484
};
8585

@@ -130,27 +130,15 @@ class EventsExample extends Example {
130130

131131
app.on('update', (dt) => {
132132
// on update, iterate over any currently highlighted boxes and reduce their emmisive property
133-
let popBoxCount = 0;
134133
highlightedBoxes.forEach((box: pc.Entity) => {
135134
// @ts-ignore engine-tsd
136-
let emissive = box.model.material.emissive;
137-
emissive = new pc.Vec3(emissive.r, emissive.g, emissive.b);
138-
emissive.scale(0.92);
139-
emissive = new pc.Color(emissive.data);
140-
if (emissive.r < 0.001 && emissive.g < 0.001 && emissive.b < 0.001) {
141-
// @ts-ignore engine-tsd
142-
box.model.material.emissive = new pc.Color(0, 0, 0);
143-
popBoxCount++;
144-
} else {
145-
// @ts-ignore engine-tsd
146-
box.model.material.emissive = emissive;
147-
}
135+
const emissive = box.model.material.emissive;
136+
emissive.lerp(emissive, pc.Color.BLACK, 0.08);
148137
box.model.material.update();
149138
});
150-
// if a box is no longer emissive, it should be removed from the list
151-
while (popBoxCount !== 0) {
139+
// remove old highlighted boxes from the update loop
140+
while (highlightedBoxes.length > 5) {
152141
highlightedBoxes.shift();
153-
popBoxCount--;
154142
}
155143

156144
// set the camera to folow the model

examples/src/examples/graphics/lights.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class LightsExample extends Example {
222222
lights[pathArray[1]].enabled = value;
223223
} else {
224224
// @ts-ignore
225-
lights[pathArray[1]][pathArray[2]] = value;
225+
lights[pathArray[1]].light[pathArray[2]] = value;
226226
}
227227
});
228228
}

examples/src/examples/user-interface/various.tsx

Lines changed: 0 additions & 301 deletions
This file was deleted.

src/anim/controller/anim-blend-tree-2d-cartesian.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class AnimBlendTreeCartesian2D extends AnimBlendTree {
3333
for (i = 0; i < this._children.length; i++) {
3434
const child = this._children[i];
3535
pi = child.point;
36-
AnimBlendTreeCartesian2D._pip.set(...AnimBlendTreeCartesian2D._p.data).sub(pi);
36+
AnimBlendTreeCartesian2D._pip.set(AnimBlendTreeCartesian2D._p.x, AnimBlendTreeCartesian2D._p.y).sub(pi);
3737
minj = Number.MAX_VALUE;
3838
for (j = 0; j < this._children.length; j++) {
3939
if (i === j) continue;

0 commit comments

Comments
 (0)