Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI + Updated ESLint for v1 #6879

Merged
merged 4 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: CI
on:
workflow_dispatch:
push:
branches: [ main ]
branches: [ main, main_v1 ]
pull_request:
branches: [ main ]
branches: [ main, main_v1 ]

concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
Expand Down
1,931 changes: 951 additions & 980 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
"parserOptions": {
"requireConfigFile": false
},
"ignorePatterns": ["tests/**/*"],
"rules": {
"import/order": "off",
"jsdoc/check-tag-names": [
"error",
{
Expand Down Expand Up @@ -106,7 +108,7 @@
"@babel/eslint-parser": "^7.24.1",
"@babel/preset-env": "^7.24.4",
"@playcanvas/canvas-mock": "^1.0.1",
"@playcanvas/eslint-config": "^1.7.1",
"@playcanvas/eslint-config": "^1.7.4",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-strip": "^3.0.4",
Expand Down
8 changes: 4 additions & 4 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { typesFixup } from './utils/plugins/rollup-types-fixup.mjs';

const BLUE_OUT = '\x1b[34m';
const RED_OUT = '\x1b[31m';
const BOLD_OUT = `\x1b[1m`;
const REGULAR_OUT = `\x1b[22m`;
const RESET_OUT = `\x1b[0m`;
const BOLD_OUT = '\x1b[1m';
const REGULAR_OUT = '\x1b[22m';
const RESET_OUT = '\x1b[0m';

/**
* @type {['release', 'debug', 'profiler', 'min']}
Expand Down Expand Up @@ -53,7 +53,7 @@ const TYPES_TARGET = [{
const envTarget = process.env.target ? process.env.target.toLowerCase() : null;

const title = [
`Building PlayCanvas Engine`,
'Building PlayCanvas Engine',
`version ${BOLD_OUT}v${version}${REGULAR_OUT}`,
`revision ${BOLD_OUT}${revision}${REGULAR_OUT}`,
`target ${BOLD_OUT}${envTarget ?? 'all'}${REGULAR_OUT}`
Expand Down
72 changes: 36 additions & 36 deletions scripts/animation/tween.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,47 +271,47 @@ Tween.prototype.start = function (idx) {
updateProperty(startValue);

tweenInstances[idx] = new TWEEN.Tween(startValue)
.to(endValue, tween.duration)
.easing(easingFunc)
.onStart(function (obj) {
if (tween.startEvent !== '') {
app.fire(tween.startEvent);
}
})
.onStop(function (obj) {
if (tween.stopEvent !== '') {
app.fire(tween.stopEvent);
}
tweenInstances[idx] = null;
})
.onUpdate(function (obj) {
updateProperty(obj);
.to(endValue, tween.duration)
.easing(easingFunc)
.onStart((obj) => {
if (tween.startEvent !== '') {
app.fire(tween.startEvent);
}
})
.onStop((obj) => {
if (tween.stopEvent !== '') {
app.fire(tween.stopEvent);
}
tweenInstances[idx] = null;
})
.onUpdate((obj) => {
updateProperty(obj);

if (tween.updateEvent !== '') {
app.fire(tween.updateEvent);
}
})
.onComplete(function (obj) {
if (tween.completeEvent !== '') {
app.fire(tween.completeEvent);
}
tweenInstances[idx] = null;
})
.onRepeat(function (obj) {
if (tween.repeatEvent !== '') {
app.fire(tween.repeatEvent);
}
})
.repeat(tween.repeat === -1 ? Infinity : tween.repeat)
.repeatDelay(tween.repeatDelay)
.yoyo(tween.yoyo)
.delay(tween.delay)
.start();
if (tween.updateEvent !== '') {
app.fire(tween.updateEvent);
}
})
.onComplete((obj) => {
if (tween.completeEvent !== '') {
app.fire(tween.completeEvent);
}
tweenInstances[idx] = null;
})
.onRepeat((obj) => {
if (tween.repeatEvent !== '') {
app.fire(tween.repeatEvent);
}
})
.repeat(tween.repeat === -1 ? Infinity : tween.repeat)
.repeatDelay(tween.repeatDelay)
.yoyo(tween.yoyo)
.delay(tween.delay)
.start();
};

// We have to update the tween.js engine somewhere once a frame...
if (pc.Application.getApplication()) {
pc.Application.getApplication().on('update', function (dt) {
pc.Application.getApplication().on('update', (dt) => {
TWEEN.update();
});
}
12 changes: 6 additions & 6 deletions scripts/camera/first-person-camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ CharacterController.prototype.jump = function () {
this.entity.rigidbody.applyImpulse(0, this.jumpImpulse, 0);
this.onGround = false;
this.jumping = true;
setTimeout(function () {
setTimeout(() => {
this.jumping = false;
}.bind(this), 500);
}, 500);
}
};

Expand Down Expand Up @@ -507,12 +507,12 @@ GamePadInput.prototype.initialize = function () {

// Manage DOM event listeners
var addEventListeners = function () {
window.addEventListener("gamepadconnected", function (e) {});
window.addEventListener("gamepaddisconnected", function (e) {});
window.addEventListener('gamepadconnected', (e) => {});
window.addEventListener('gamepaddisconnected', (e) => {});
};
var removeEventListeners = function () {
window.removeEventListener("gamepadconnected", function (e) {});
window.removeEventListener("gamepaddisconnected", function (e) {});
window.removeEventListener('gamepadconnected', (e) => {});
window.removeEventListener('gamepaddisconnected', (e) => {});
};

this.on('enable', addEventListeners);
Expand Down
10 changes: 6 additions & 4 deletions scripts/camera/fly-camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ FlyCamera.attributes.add('mode', {
type: 'number',
default: 0,
enum: [{
"Lock": 0
'Lock': 0
}, {
"Drag": 1
'Drag': 1
}]
});

Expand Down Expand Up @@ -63,11 +63,13 @@ FlyCamera.prototype.update = function (dt) {

FlyCamera.prototype.onMouseMove = function (event) {
if (!this.mode) {
if (!pc.Mouse.isPointerLocked())
if (!pc.Mouse.isPointerLocked()) {
return;
}
} else {
if (!this.lmbDown)
if (!this.lmbDown) {
return;
}
}


Expand Down
18 changes: 9 additions & 9 deletions scripts/camera/orbit-camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ OrbitCamera.attributes.add('frameOnStart', {

// Property to get and set the distance between the pivot point and camera
// Clamped between this.distanceMin and this.distanceMax
Object.defineProperty(OrbitCamera.prototype, "distance", {
Object.defineProperty(OrbitCamera.prototype, 'distance', {
get: function () {
return this._targetDistance;
},
Expand All @@ -43,7 +43,7 @@ Object.defineProperty(OrbitCamera.prototype, "distance", {

// Property to get and set the camera orthoHeight
// Clamped above 0
Object.defineProperty(OrbitCamera.prototype, "orthoHeight", {
Object.defineProperty(OrbitCamera.prototype, 'orthoHeight', {
get: function () {
return this.entity.camera.orthoHeight;
},
Expand All @@ -57,7 +57,7 @@ Object.defineProperty(OrbitCamera.prototype, "orthoHeight", {
// Property to get and set the pitch of the camera around the pivot point (degrees)
// Clamped between this.pitchAngleMin and this.pitchAngleMax
// When set at 0, the camera angle is flat, looking along the horizon
Object.defineProperty(OrbitCamera.prototype, "pitch", {
Object.defineProperty(OrbitCamera.prototype, 'pitch', {
get: function () {
return this._targetPitch;
},
Expand All @@ -69,7 +69,7 @@ Object.defineProperty(OrbitCamera.prototype, "pitch", {


// Property to get and set the yaw of the camera around the pivot point (degrees)
Object.defineProperty(OrbitCamera.prototype, "yaw", {
Object.defineProperty(OrbitCamera.prototype, 'yaw', {
get: function () {
return this._targetYaw;
},
Expand All @@ -94,7 +94,7 @@ Object.defineProperty(OrbitCamera.prototype, "yaw", {


// Property to get and set the world position of the pivot point that the camera orbits around
Object.defineProperty(OrbitCamera.prototype, "pivotPoint", {
Object.defineProperty(OrbitCamera.prototype, 'pivotPoint', {
get: function () {
return this._pivotPoint;
},
Expand Down Expand Up @@ -244,7 +244,7 @@ OrbitCamera.prototype.initialize = function () {
}
});

this.on('destroy', function () {
this.on('destroy', () => {
window.removeEventListener('resize', onWindowResize, false);
});
};
Expand Down Expand Up @@ -294,23 +294,23 @@ OrbitCamera.prototype._checkAspectRatio = function () {
OrbitCamera.prototype._buildAabb = function (entity) {
var i, m, meshInstances = [];

var renders = entity.findComponents("render");
var renders = entity.findComponents('render');
for (i = 0; i < renders.length; i++) {
var render = renders[i];
for (m = 0; m < render.meshInstances.length; m++) {
meshInstances.push(render.meshInstances[m]);
}
}

var models = entity.findComponents("model");
var models = entity.findComponents('model');
for (i = 0; i < models.length; i++) {
var model = models[i];
for (m = 0; m < model.meshInstances.length; m++) {
meshInstances.push(model.meshInstances[m]);
}
}

var gsplats = entity.findComponents("gsplat");
var gsplats = entity.findComponents('gsplat');
for (i = 0; i < gsplats.length; i++) {
var gsplat = gsplats[i];
var instance = gsplat.instance;
Expand Down
36 changes: 21 additions & 15 deletions scripts/parsers/obj-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Object.assign(ObjModelParser.prototype, {
indices: []
}
};
var group = "default"; // current group
var lines = input.split("\n");
var group = 'default'; // current group
var lines = input.split('\n');
var verts = [], normals = [], uvs = [];
var i;

Expand Down Expand Up @@ -71,10 +71,12 @@ Object.assign(ObjModelParser.prototype, {
for (p = 1; p < parts.length; p++) {
r = this._parseIndices(parts[p]);
parsed[group].verts.push(verts[r[0] * 3], verts[r[0] * 3 + 1], verts[r[0] * 3 + 2]); // expand uvs from indices
if (r[1] * 2 < uvs.length)
parsed[group].uvs.push(uvs[r[1] * 2], uvs[r[1] * 2 + 1]); // expand uvs from indices
if (r[2] * 3 < normals.length)
parsed[group].normals.push(normals[r[2] * 3], normals[r[2] * 3 + 1], normals[r[2] * 3 + 2]); // expand normals from indices
if (r[1] * 2 < uvs.length) {
parsed[group].uvs.push(uvs[r[1] * 2], uvs[r[1] * 2 + 1]);
} // expand uvs from indices
if (r[2] * 3 < normals.length) {
parsed[group].normals.push(normals[r[2] * 3], normals[r[2] * 3 + 1], normals[r[2] * 3 + 2]);
} // expand normals from indices
}

} else if (parts.length === 5) {
Expand All @@ -84,13 +86,15 @@ Object.assign(ObjModelParser.prototype, {
p = order[o];
r = this._parseIndices(parts[p]);
parsed[group].verts.push(verts[r[0] * 3], verts[r[0] * 3 + 1], verts[r[0] * 3 + 2]); // expand uvs from indices
if (r[1] * 2 < uvs.length)
parsed[group].uvs.push(uvs[r[1] * 2], uvs[r[1] * 2 + 1]); // expand uvs from indices
if (r[2] * 3 < normals.length)
parsed[group].normals.push(normals[r[2] * 3], normals[r[2] * 3 + 1], normals[r[2] * 3 + 2]); // expand normals from indices
if (r[1] * 2 < uvs.length) {
parsed[group].uvs.push(uvs[r[1] * 2], uvs[r[1] * 2 + 1]);
} // expand uvs from indices
if (r[2] * 3 < normals.length) {
parsed[group].normals.push(normals[r[2] * 3], normals[r[2] * 3 + 1], normals[r[2] * 3 + 2]);
} // expand normals from indices
}
} else {
console.error(pc.string.format("OBJ uses unsupported {0}-gons", parts.length - 1));
console.error(pc.string.format('OBJ uses unsupported {0}-gons', parts.length - 1));
}
}
}
Expand All @@ -103,15 +107,17 @@ Object.assign(ObjModelParser.prototype, {
var currentGroup = parsed[groupNames[i]];
if (!currentGroup.verts.length) continue;
if (currentGroup.verts.length > 65535) {
console.warn("Warning: mesh with more than 65535 vertices");
console.warn('Warning: mesh with more than 65535 vertices');
}

var geom = new pc.Geometry();
geom.positions = currentGroup.verts;
if (currentGroup.normals.length > 0)
if (currentGroup.normals.length > 0) {
geom.normals = currentGroup.normals;
if (currentGroup.uvs.length > 0)
}
if (currentGroup.uvs.length > 0) {
geom.uvs = currentGroup.uvs;
}

var mesh = pc.Mesh.fromGeometry(this._device, geom);

Expand All @@ -126,7 +132,7 @@ Object.assign(ObjModelParser.prototype, {

_parseIndices: function (str) {
var result = [];
var indices = str.split("/");
var indices = str.split('/');
for (var i = 0; i < 3; i++) {
if (indices[i]) {
result[i] = parseInt(indices[i], 10) - 1; // convert to 0-indexed
Expand Down
2 changes: 1 addition & 1 deletion scripts/physics/action-physics-reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ActionPhysicsReset.prototype.postInitialize = function () {
app.on(this.event, reset);
}

this.on('attr:event', function (value, prev) {
this.on('attr:event', (value, prev) => {
if (prev && prev.length > 0) {
app.off(prev, reset);
}
Expand Down
Loading