Skip to content

Commit

Permalink
Partial migration to single quotes (#4155)
Browse files Browse the repository at this point in the history
* Partial migration to single quotes in src folder

* Migrate extras

* Migrate rollup.config.js
  • Loading branch information
willeastcott authored Apr 1, 2022
1 parent a0ddc12 commit 992f436
Show file tree
Hide file tree
Showing 37 changed files with 319 additions and 319 deletions.
2 changes: 1 addition & 1 deletion extras/mini-stats/cpu-timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class CpuTimer {
this._frameTimings = [];
this._timings = [];
this._prevTimings = [];
this.unitsName = "ms";
this.unitsName = 'ms';
this.decimalPlaces = 1;

this.enabled = true;
Expand Down
4 changes: 2 additions & 2 deletions extras/mini-stats/gpu-timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class GpuTimer {
this._prevTimings = [];

this.enabled = true;
this.unitsName = "ms";
this.unitsName = 'ms';
this.decimalPlaces = 1;

app.on('frameupdate', this.begin.bind(this, 'update'));
Expand Down Expand Up @@ -100,7 +100,7 @@ class GpuTimer {
// either returns a previously free'd query or if there aren't any allocates a new one
_allocateQuery() {
return (this._freeQueries.length > 0) ?
this._freeQueries.splice(-1, 1)[0] : ["", this._gl.createQuery()];
this._freeQueries.splice(-1, 1)[0] : ['', this._gl.createQuery()];
}

// attempt to resolve one frame's worth of timings
Expand Down
2 changes: 1 addition & 1 deletion extras/mini-stats/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Graph {
this.avgTotal = 0;
this.avgTimer = 0;
this.avgCount = 0;
this.timingText = "";
this.timingText = '';

this.texture = null;
this.yOffset = 0;
Expand Down
24 changes: 12 additions & 12 deletions extras/mini-stats/mini-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class MiniStats {
}
}
};
device.canvas.addEventListener("webglcontextlost", this._contextLostHandler, false);
device.canvas.addEventListener('webglcontextlost', this._contextLostHandler, false);

options = options || MiniStats.getDefaultOptions();

// create graphs based on options
const graphs = this.initGraphs(app, device, options);

// extract words needed
let words = ["", "ms", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "."];
let words = ['', 'ms', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.'];

// graph names
graphs.forEach((graph) => {
Expand Down Expand Up @@ -86,7 +86,7 @@ class MiniStats {
}
});

device.on("resizecanvas", () => {
device.on('resizecanvas', () => {
this.updateDiv();
});

Expand Down Expand Up @@ -155,25 +155,25 @@ class MiniStats {
stats: [
{
// display name
name: "Frame",
name: 'Frame',

// path to data inside pc.Application.stats
stats: ["frame.ms"],
stats: ['frame.ms'],

// number of decimal places (defaults to none)
decimalPlaces: 1,

// units (defaults to "")
unitsName: "ms",
unitsName: 'ms',

// watermark - shown as a line on the graph, useful for displaying a budget
watermark: 33
},

// total number of draw calls
{
name: "DrawCalls",
stats: ["drawCalls.total"],
name: 'DrawCalls',
stats: ['drawCalls.total'],
watermark: 1000
}
]
Expand Down Expand Up @@ -323,10 +323,10 @@ class MiniStats {

updateDiv() {
const rect = this.device.canvas.getBoundingClientRect();
this.div.style.left = rect.left + "px";
this.div.style.bottom = (window.innerHeight - rect.bottom) + "px";
this.div.style.width = this.width + "px";
this.div.style.height = this.overallHeight + "px";
this.div.style.left = rect.left + 'px';
this.div.style.bottom = (window.innerHeight - rect.bottom) + 'px';
this.div.style.width = this.width + 'px';
this.div.style.height = this.overallHeight + 'px';
}
}

Expand Down
14 changes: 7 additions & 7 deletions extras/mini-stats/render2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Render2d {
this.shader = pc.shaderChunks.createShaderFromCode(device,
vertexShader,
fragmentShader,
"mini-stats");
'mini-stats');
this.buffer = new pc.VertexBuffer(device, format, maxQuads * 4, pc.BUFFER_STREAM);
this.data = new Float32Array(this.buffer.numBytes / 4);

Expand All @@ -87,13 +87,13 @@ class Render2d {
// colors
const setupColor = (name, value) => {
this[name] = new Float32Array([value.r, value.g, value.b, value.a]);
this[name + "Id"] = device.scope.resolve(name);
this[name + 'Id'] = device.scope.resolve(name);
};
setupColor("col0", colors.graph0);
setupColor("col1", colors.graph1);
setupColor("col2", colors.graph2);
setupColor("watermark", colors.watermark);
setupColor("background", colors.background);
setupColor('col0', colors.graph0);
setupColor('col1', colors.graph1);
setupColor('col2', colors.graph2);
setupColor('watermark', colors.watermark);
setupColor('background', colors.background);

this.watermarkSizeId = device.scope.resolve('watermarkSize');
this.clrId = device.scope.resolve('clr');
Expand Down
8 changes: 4 additions & 4 deletions extras/mini-stats/word-atlas.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class WordAtlas {
// configure the context
const context = canvas.getContext('2d', { alpha: true });
context.font = '10px "Lucida Console", Monaco, monospace';
context.textAlign = "left";
context.textBaseline = "alphabetic";
context.fillStyle = "rgb(255, 255, 255)";
context.textAlign = 'left';
context.textBaseline = 'alphabetic';
context.fillStyle = 'rgb(255, 255, 255)';

const padding = 5;
let x = padding;
Expand All @@ -36,7 +36,7 @@ class WordAtlas {
}

// digits and '.' are white, the rest grey
context.fillStyle = words[i].length === 1 ? "rgb(255, 255, 255)" : "rgb(150, 150, 150)";
context.fillStyle = words[i].length === 1 ? 'rgb(255, 255, 255)' : 'rgb(150, 150, 150)';

// render the word
context.fillText(words[i], x - l, y + a);
Expand Down
22 changes: 11 additions & 11 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import babel from '@rollup/plugin-babel';
import replace from '@rollup/plugin-replace';
import strip from '@rollup/plugin-strip';
import { createFilter } from '@rollup/pluginutils';
import dts from "rollup-plugin-dts";
import dts from 'rollup-plugin-dts';
import jscc from 'rollup-plugin-jscc';
import { terser } from 'rollup-plugin-terser';
import { version } from './package.json';
Expand Down Expand Up @@ -102,7 +102,7 @@ const es5Options = {
loose: true,
modules: false,
targets: {
ie: "11"
ie: '11'
}
}
]
Expand Down Expand Up @@ -299,11 +299,11 @@ const target_extras = [
];

const target_types = {
input: "types/index.d.ts",
input: 'types/index.d.ts',
output: [{
file: "build/playcanvas.d.ts",
footer: "export as namespace pc;",
format: "es"
file: 'build/playcanvas.d.ts',
footer: 'export as namespace pc;',
format: 'es'
}],
plugins: [
dts()
Expand All @@ -314,11 +314,11 @@ let targets;

if (process.env.target) { // Build a specific target
switch (process.env.target.toLowerCase()) {
case "es5": targets = [target_release_es5]; break;
case "es6": targets = [target_release_es6]; break;
case "debug": targets = [target_debug]; break;
case "profiler": targets = [target_profiler]; break;
case "types": targets = [target_types]; break;
case 'es5': targets = [target_release_es5]; break;
case 'es6': targets = [target_release_es6]; break;
case 'debug': targets = [target_debug]; break;
case 'profiler': targets = [target_profiler]; break;
case 'types': targets = [target_types]; break;
}
} else { // Build all targets
targets = [
Expand Down
2 changes: 1 addition & 1 deletion src/animation/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Node {
* Create a new Node instance.
*/
constructor() {
this._name = "";
this._name = '';
this._keys = [];
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/animation/skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Vec3 } from '../math/vec3.js';
class InterpolatedKey {
constructor() {
this._written = false;
this._name = "";
this._name = '';
this._keyFrames = [];

// Result of interpolation
Expand Down
12 changes: 6 additions & 6 deletions src/asset/asset-localized.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ class LocalizedAsset extends EventHandler {
const asset = this._app.assets.get(this._localizedAsset);
if (!asset) return;

asset.on("load", this._onLocalizedAssetLoad, this);
asset.on("change", this._onLocalizedAssetChange, this);
asset.on("remove", this._onLocalizedAssetRemove, this);
asset.on('load', this._onLocalizedAssetLoad, this);
asset.on('change', this._onLocalizedAssetChange, this);
asset.on('remove', this._onLocalizedAssetRemove, this);

if (asset.resource) {
this._onLocalizedAssetLoad(asset);
Expand All @@ -153,9 +153,9 @@ class LocalizedAsset extends EventHandler {
const asset = this._app.assets.get(this._localizedAsset);
if (!asset) return;

asset.off("load", this._onLocalizedAssetLoad, this);
asset.off("change", this._onLocalizedAssetChange, this);
asset.off("remove", this._onLocalizedAssetRemove, this);
asset.off('load', this._onLocalizedAssetLoad, this);
asset.off('change', this._onLocalizedAssetChange, this);
asset.off('remove', this._onLocalizedAssetRemove, this);
}

_onLocalizedAssetAdd(asset) {
Expand Down
20 changes: 10 additions & 10 deletions src/asset/asset-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class AssetReference {
* @type {number}
*/
set id(value) {
if (this.url) throw Error("Can't set id and url");
if (this.url) throw Error('Can\'t set id and url');

this._unbind();

Expand All @@ -79,7 +79,7 @@ class AssetReference {
* @type {string}
*/
set url(value) {
if (this.id) throw Error("Can't set id and url");
if (this.id) throw Error('Can\'t set id and url');

this._unbind();

Expand All @@ -95,16 +95,16 @@ class AssetReference {

_bind() {
if (this.id) {
if (this._onAssetLoad) this._registry.on("load:" + this.id, this._onLoad, this);
if (this._onAssetAdd) this._registry.once("add:" + this.id, this._onAdd, this);
if (this._onAssetRemove) this._registry.on("remove:" + this.id, this._onRemove, this);
if (this._onAssetUnload) this._registry.on("unload:" + this.id, this._onUnload, this);
if (this._onAssetLoad) this._registry.on('load:' + this.id, this._onLoad, this);
if (this._onAssetAdd) this._registry.once('add:' + this.id, this._onAdd, this);
if (this._onAssetRemove) this._registry.on('remove:' + this.id, this._onRemove, this);
if (this._onAssetUnload) this._registry.on('unload:' + this.id, this._onUnload, this);
}

if (this.url) {
if (this._onAssetLoad) this._registry.on("load:url:" + this.url, this._onLoad, this);
if (this._onAssetAdd) this._registry.once("add:url:" + this.url, this._onAdd, this);
if (this._onAssetRemove) this._registry.on("remove:url:" + this.url, this._onRemove, this);
if (this._onAssetLoad) this._registry.on('load:url:' + this.url, this._onLoad, this);
if (this._onAssetAdd) this._registry.once('add:url:' + this.url, this._onAdd, this);
if (this._onAssetRemove) this._registry.on('remove:url:' + this.url, this._onRemove, this);
}
}

Expand All @@ -113,7 +113,7 @@ class AssetReference {
if (this._onAssetLoad) this._registry.off('load:' + this.id, this._onLoad, this);
if (this._onAssetAdd) this._registry.off('add:' + this.id, this._onAdd, this);
if (this._onAssetRemove) this._registry.off('remove:' + this.id, this._onRemove, this);
if (this._onAssetUnload) this._registry.off("unload:" + this.id, this._onUnload, this);
if (this._onAssetUnload) this._registry.off('unload:' + this.id, this._onUnload, this);
}
if (this.url) {
if (this._onAssetLoad) this._registry.off('load:' + this.url, this._onLoad, this);
Expand Down
Loading

0 comments on commit 992f436

Please sign in to comment.