Skip to content

Commit bd28154

Browse files
authored
Update var to let and const in deprecated.js (playcanvas#3453)
1 parent 170b978 commit bd28154

File tree

1 file changed

+40
-43
lines changed

1 file changed

+40
-43
lines changed

src/deprecated.js

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ import { basisInitialize } from './resources/basis.js';
113113

114114
// CORE
115115

116-
export var log = {
116+
export const log = {
117117
write: function (text) {
118118
// #if _DEBUG
119119
console.warn("DEPRECATED: pc.log.write is deprecated. Use console.log instead.");
@@ -188,7 +188,7 @@ string.startsWith = function (s, subs) {
188188
return s.startsWith(subs);
189189
};
190190

191-
export var time = {
191+
export const time = {
192192
now: now,
193193
Timer: Timer
194194
};
@@ -225,8 +225,8 @@ Object.defineProperty(Color.prototype, "data3", {
225225
});
226226

227227
export function inherits(Self, Super) {
228-
var Temp = function () {};
229-
var Func = function (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
228+
const Temp = function () {};
229+
const Func = function (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
230230
Super.call(this, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
231231
Self.call(this, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
232232
// this.constructor = Self;
@@ -305,7 +305,7 @@ Vec4.prototype.scale = Vec4.prototype.mulScalar;
305305

306306
// SHAPE
307307

308-
export var shape = {
308+
export const shape = {
309309
Aabb: BoundingBox,
310310
Sphere: BoundingSphere,
311311
Plane: Plane
@@ -318,7 +318,7 @@ Frustum.prototype.update = function (projectionMatrix, viewMatrix) {
318318
console.warn('DEPRECATED: pc.Frustum#update is deprecated. Use pc.Frustum#setFromMat4 instead.');
319319
// #endif
320320

321-
var viewProj = new Mat4();
321+
const viewProj = new Mat4();
322322

323323
viewProj.mul2(projectionMatrix, viewMatrix);
324324

@@ -327,13 +327,13 @@ Frustum.prototype.update = function (projectionMatrix, viewMatrix) {
327327

328328
// GRAPHICS
329329

330-
export var ELEMENTTYPE_INT8 = TYPE_INT8;
331-
export var ELEMENTTYPE_UINT8 = TYPE_UINT8;
332-
export var ELEMENTTYPE_INT16 = TYPE_INT16;
333-
export var ELEMENTTYPE_UINT16 = TYPE_UINT16;
334-
export var ELEMENTTYPE_INT32 = TYPE_INT32;
335-
export var ELEMENTTYPE_UINT32 = TYPE_UINT32;
336-
export var ELEMENTTYPE_FLOAT32 = TYPE_FLOAT32;
330+
export const ELEMENTTYPE_INT8 = TYPE_INT8;
331+
export const ELEMENTTYPE_UINT8 = TYPE_UINT8;
332+
export const ELEMENTTYPE_INT16 = TYPE_INT16;
333+
export const ELEMENTTYPE_UINT16 = TYPE_UINT16;
334+
export const ELEMENTTYPE_INT32 = TYPE_INT32;
335+
export const ELEMENTTYPE_UINT32 = TYPE_UINT32;
336+
export const ELEMENTTYPE_FLOAT32 = TYPE_FLOAT32;
337337

338338
export function UnsupportedBrowserError(message) {
339339
this.name = "UnsupportedBrowserError";
@@ -347,7 +347,7 @@ export function ContextCreationError(message) {
347347
}
348348
ContextCreationError.prototype = Error.prototype;
349349

350-
export var gfx = {
350+
export const gfx = {
351351
ADDRESS_CLAMP_TO_EDGE: ADDRESS_CLAMP_TO_EDGE,
352352
ADDRESS_MIRRORED_REPEAT: ADDRESS_MIRRORED_REPEAT,
353353
ADDRESS_REPEAT: ADDRESS_REPEAT,
@@ -425,7 +425,7 @@ export var gfx = {
425425
VertexIterator: VertexIterator
426426
};
427427

428-
export var posteffect = {
428+
export const posteffect = {
429429
createFullscreenQuad: createFullscreenQuad,
430430
drawFullscreenQuad: drawFullscreenQuad,
431431
PostEffect: PostEffect,
@@ -472,9 +472,9 @@ Object.defineProperties(Texture.prototype, {
472472

473473
// SCENE
474474

475-
export var PhongMaterial = StandardMaterial;
475+
export const PhongMaterial = StandardMaterial;
476476

477-
export var scene = {
477+
export const scene = {
478478
partitionSkin: partitionSkin,
479479
procedural: {
480480
calculateTangents: calculateTangents,
@@ -567,19 +567,16 @@ GraphNode.prototype.removeLabel = function (label) {
567567
delete this._labels[label];
568568
};
569569

570-
GraphNode.prototype.findByLabel = function (label, results) {
570+
GraphNode.prototype.findByLabel = function (label, results = []) {
571571
// #if _DEBUG
572572
console.warn('DEPRECATED: pc.GraphNode#findByLabel is deprecated. Use pc.GraphNode#tags instead.');
573573
// #endif
574574

575-
var i, length = this._children.length;
576-
results = results || [];
577-
578575
if (this.hasLabel(label)) {
579576
results.push(this);
580577
}
581578

582-
for (i = 0; i < length; ++i) {
579+
for (let i = 0; i < this._children.length; ++i) {
583580
results = this._children[i].findByLabel(label, results);
584581
}
585582

@@ -664,7 +661,7 @@ Material.prototype.setShader = function (shader) {
664661

665662
// ANIMATION
666663

667-
export var anim = {
664+
export const anim = {
668665
Animation: Animation,
669666
Key: Key,
670667
Node: Node,
@@ -757,7 +754,7 @@ Skeleton.prototype.setLooping = function (looping) {
757754

758755
// SOUND
759756

760-
export var audio = {
757+
export const audio = {
761758
AudioManager: SoundManager,
762759
Channel: Channel,
763760
Channel3d: Channel3d,
@@ -788,7 +785,7 @@ SoundManager.prototype.setVolume = function (volume) {
788785

789786
// ASSET
790787

791-
export var asset = {
788+
export const asset = {
792789
ASSET_ANIMATION: 'animation',
793790
ASSET_AUDIO: 'audio',
794791
ASSET_IMAGE: 'image',
@@ -839,7 +836,7 @@ Object.defineProperty(XrInputSource.prototype, 'rotation', {
839836

840837
// INPUT
841838

842-
export var input = {
839+
export const input = {
843840
getTouchTargetCoords: getTouchTargetCoords,
844841
Controller: Controller,
845842
GamePads: GamePads,
@@ -866,19 +863,19 @@ Object.defineProperty(MouseEvent.prototype, 'wheel', {
866863

867864
// FRAMEWORK
868865

869-
export var RIGIDBODY_TYPE_STATIC = BODYTYPE_STATIC;
870-
export var RIGIDBODY_TYPE_DYNAMIC = BODYTYPE_DYNAMIC;
871-
export var RIGIDBODY_TYPE_KINEMATIC = BODYTYPE_KINEMATIC;
872-
export var RIGIDBODY_CF_STATIC_OBJECT = BODYFLAG_STATIC_OBJECT;
873-
export var RIGIDBODY_CF_KINEMATIC_OBJECT = BODYFLAG_KINEMATIC_OBJECT;
874-
export var RIGIDBODY_CF_NORESPONSE_OBJECT = BODYFLAG_NORESPONSE_OBJECT;
875-
export var RIGIDBODY_ACTIVE_TAG = BODYSTATE_ACTIVE_TAG;
876-
export var RIGIDBODY_ISLAND_SLEEPING = BODYSTATE_ISLAND_SLEEPING;
877-
export var RIGIDBODY_WANTS_DEACTIVATION = BODYSTATE_WANTS_DEACTIVATION;
878-
export var RIGIDBODY_DISABLE_DEACTIVATION = BODYSTATE_DISABLE_DEACTIVATION;
879-
export var RIGIDBODY_DISABLE_SIMULATION = BODYSTATE_DISABLE_SIMULATION;
880-
881-
export var fw = {
866+
export const RIGIDBODY_TYPE_STATIC = BODYTYPE_STATIC;
867+
export const RIGIDBODY_TYPE_DYNAMIC = BODYTYPE_DYNAMIC;
868+
export const RIGIDBODY_TYPE_KINEMATIC = BODYTYPE_KINEMATIC;
869+
export const RIGIDBODY_CF_STATIC_OBJECT = BODYFLAG_STATIC_OBJECT;
870+
export const RIGIDBODY_CF_KINEMATIC_OBJECT = BODYFLAG_KINEMATIC_OBJECT;
871+
export const RIGIDBODY_CF_NORESPONSE_OBJECT = BODYFLAG_NORESPONSE_OBJECT;
872+
export const RIGIDBODY_ACTIVE_TAG = BODYSTATE_ACTIVE_TAG;
873+
export const RIGIDBODY_ISLAND_SLEEPING = BODYSTATE_ISLAND_SLEEPING;
874+
export const RIGIDBODY_WANTS_DEACTIVATION = BODYSTATE_WANTS_DEACTIVATION;
875+
export const RIGIDBODY_DISABLE_DEACTIVATION = BODYSTATE_DISABLE_DEACTIVATION;
876+
export const RIGIDBODY_DISABLE_SIMULATION = BODYSTATE_DISABLE_SIMULATION;
877+
878+
export const fw = {
882879
Application: Application,
883880
Component: Component,
884881
ComponentSystem: ComponentSystem,
@@ -910,13 +907,13 @@ Application.prototype.enableFullscreen = function (element, success, error) {
910907
element = element || this.graphicsDevice.canvas;
911908

912909
// success callback
913-
var s = function () {
910+
const s = function () {
914911
success();
915912
document.removeEventListener('fullscreenchange', s);
916913
};
917914

918915
// error callback
919-
var e = function () {
916+
const e = function () {
920917
error();
921918
document.removeEventListener('fullscreenerror', e);
922919
};
@@ -942,7 +939,7 @@ Application.prototype.disableFullscreen = function (success) {
942939
// #endif
943940

944941
// success callback
945-
var s = function () {
942+
const s = function () {
946943
success();
947944
document.removeEventListener('fullscreenchange', s);
948945
};
@@ -958,7 +955,7 @@ Application.prototype.getSceneUrl = function (name) {
958955
// #if _DEBUG
959956
console.warn("DEPRECATED: pc.Application#getSceneUrl is deprecated. Use pc.Application#scenes and pc.SceneRegistry#find instead.");
960957
// #endif
961-
var entry = this.scenes.find(name);
958+
const entry = this.scenes.find(name);
962959
if (entry) {
963960
return entry.url;
964961
}

0 commit comments

Comments
 (0)