diff --git a/rollup.config.js b/rollup.config.js index 4ceff886b52..413fd9bdd89 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -33,7 +33,7 @@ function spacesToTabs() { return { transform(code, id) { - if (!filter(id)) return; + if (!filter(id)) return undefined; return { code: code.replace(/ {2}/g, '\t'), map: null @@ -50,7 +50,7 @@ function shaderChunks(removeComments) { return { transform(code, id) { - if (!filter(id)) return; + if (!filter(id)) return undefined; code = code.replace(/\/\* glsl \*\/\`((.|\r|\n)*)\`/, (match, glsl) => { diff --git a/src/anim/controller/anim-controller.js b/src/anim/controller/anim-controller.js index 7e57ca9c3a7..f22f36b8be2 100644 --- a/src/anim/controller/anim-controller.js +++ b/src/anim/controller/anim-controller.js @@ -472,12 +472,12 @@ class AnimController { removeNodeAnimations(nodeName) { if (ANIM_CONTROL_STATES.indexOf(nodeName) !== -1) { - return; + return false; } const state = this._findState(nodeName); if (!state) { Debug.error('Attempting to unassign animation tracks from a state that does not exist.'); - return; + return false; } state.animations = []; diff --git a/src/anim/controller/anim-state.js b/src/anim/controller/anim-state.js index 6e4ce6cb38a..8489b6ea287 100644 --- a/src/anim/controller/anim-state.js +++ b/src/anim/controller/anim-state.js @@ -1,3 +1,5 @@ +import { Debug } from '../../core/debug.js'; + import { AnimBlendTree1D } from './anim-blend-tree-1d.js'; import { AnimBlendTreeCartesian2D } from './anim-blend-tree-2d-cartesian.js'; import { AnimBlendTreeDirectional2D } from './anim-blend-tree-2d-directional.js'; @@ -65,6 +67,9 @@ class AnimState { case ANIM_BLEND_DIRECT: return new AnimBlendTreeDirect(state, parent, name, point, parameters, children, syncAnimations, createTree, findParameter); } + + Debug.error(`Invalid anim blend type: ${type}`); + return undefined; } _getNodeFromPath(path) { diff --git a/src/framework/app-base.js b/src/framework/app-base.js index 6b66741dad2..62072e8c23a 100644 --- a/src/framework/app-base.js +++ b/src/framework/app-base.js @@ -1471,11 +1471,11 @@ class Application extends EventHandler { * @returns {object} A object containing the values calculated to use as width and height. */ resizeCanvas(width, height) { - if (!this._allowResize) return; // prevent resizing (e.g. if presenting in VR HMD) + if (!this._allowResize) return undefined; // prevent resizing (e.g. if presenting in VR HMD) // prevent resizing when in XR session if (this.xr && this.xr.session) - return; + return undefined; const windowWidth = window.innerWidth; const windowHeight = window.innerHeight; diff --git a/src/framework/components/anim/component.js b/src/framework/components/anim/component.js index 3062d4ad209..aba7780c8de 100644 --- a/src/framework/components/anim/component.js +++ b/src/framework/components/anim/component.js @@ -596,6 +596,7 @@ class AnimComponent extends Component { return param.value; } Debug.log(`Cannot get parameter value. No parameter found in anim controller named "${name}" of type "${type}"`); + return undefined; } setParameterValue(name, type, value) { diff --git a/src/framework/components/collision/system.js b/src/framework/components/collision/system.js index be77a4ed86f..06fb9fb847b 100644 --- a/src/framework/components/collision/system.js +++ b/src/framework/components/collision/system.js @@ -389,7 +389,7 @@ class CollisionMeshSystemImpl extends CollisionSystemImpl { } createPhysicalShape(entity, data) { - if (typeof Ammo === 'undefined') return; + if (typeof Ammo === 'undefined') return undefined; if (data.model || data.render) { @@ -415,6 +415,8 @@ class CollisionMeshSystemImpl extends CollisionSystemImpl { return shape; } + + return undefined; } recreatePhysicalShapes(component) { diff --git a/src/framework/components/script-legacy/component.js b/src/framework/components/script-legacy/component.js index a1c4b639ab2..079bcb0852d 100644 --- a/src/framework/components/script-legacy/component.js +++ b/src/framework/components/script-legacy/component.js @@ -21,8 +21,8 @@ class ScriptLegacyComponent extends Component { if (fn) { return fn.apply(instances[name].instance, args); } - } + return undefined; } onEnable() { diff --git a/src/framework/components/scroll-view/component.js b/src/framework/components/scroll-view/component.js index ae02617b2d7..2d23839b2c9 100644 --- a/src/framework/components/scroll-view/component.js +++ b/src/framework/components/scroll-view/component.js @@ -1,3 +1,5 @@ +import { Debug } from '../../../core/debug.js'; + import { math } from '../../../math/math.js'; import { Vec2 } from '../../../math/vec2.js'; import { Vec3 } from '../../../math/vec3.js'; @@ -441,7 +443,8 @@ class ScrollViewComponent extends Component { return this.vertical; } - console.warn('Unrecognized orientation: ' + orientation); + Debug.warn(`Unrecognized orientation: ${orientation}`); + return undefined; } _getScrollbarVisibility(orientation) { @@ -451,7 +454,8 @@ class ScrollViewComponent extends Component { return this.verticalScrollbarVisibility; } - console.warn('Unrecognized orientation: ' + orientation); + Debug.warn(`Unrecognized orientation: ${orientation}`); + return undefined; } _getSign(orientation) { diff --git a/src/framework/components/sound/slot.js b/src/framework/components/sound/slot.js index 775d82f43df..68f836d6a69 100644 --- a/src/framework/components/sound/slot.js +++ b/src/framework/components/sound/slot.js @@ -119,7 +119,7 @@ class SoundSlot extends EventHandler { // If not loaded and doesn't have asset - then we cannot play it. Warn and exit. if (!this.isLoaded && !this._hasAsset()) { Debug.warn(`Trying to play SoundSlot ${this.name} but it is not loaded and doesn't have an asset.`); - return; + return undefined; } const instance = this._createInstance(); diff --git a/src/graphics/program-lib/programs/standard.js b/src/graphics/program-lib/programs/standard.js index 4c659f86916..f7b6d86b856 100644 --- a/src/graphics/program-lib/programs/standard.js +++ b/src/graphics/program-lib/programs/standard.js @@ -105,6 +105,7 @@ const standard = { } return chan; } + return undefined; }, _setMapTransform: function (codes, name, id, uv) { diff --git a/src/graphics/reproject-texture.js b/src/graphics/reproject-texture.js index a0ad7ba3477..1df4aaead4f 100644 --- a/src/graphics/reproject-texture.js +++ b/src/graphics/reproject-texture.js @@ -3,7 +3,7 @@ import { FILTER_NEAREST, TEXTURETYPE_RGBM, TEXTURETYPE_RGBE, PIXELFORMAT_RGB16F, PIXELFORMAT_RGB32F, PIXELFORMAT_RGBA16F, PIXELFORMAT_RGBA32F, - TEXTUREPROJECTION_OCTAHEDRAL, TEXTUREPROJECTION_EQUIRECT, TEXTUREPROJECTION_CUBE, TEXTUREPROJECTION_NONE + TEXTUREPROJECTION_OCTAHEDRAL, TEXTUREPROJECTION_CUBE } from './constants.js'; import { Vec3 } from '../math/vec3.js'; import { random } from '../math/random.js'; @@ -39,14 +39,13 @@ const getCoding = (texture) => { }; const getProjectionName = (projection) => { - // default to equirect if not specified - if (projection === TEXTUREPROJECTION_NONE) { - projection = TEXTUREPROJECTION_EQUIRECT; - } switch (projection) { - case TEXTUREPROJECTION_CUBE: return "Cubemap"; - case TEXTUREPROJECTION_EQUIRECT: return "Equirect"; - case TEXTUREPROJECTION_OCTAHEDRAL: return "Octahedral"; + case TEXTUREPROJECTION_CUBE: + return "Cubemap"; + case TEXTUREPROJECTION_OCTAHEDRAL: + return "Octahedral"; + default: // for anything else, assume equirect + return "Equirect"; } }; diff --git a/src/graphics/texture.js b/src/graphics/texture.js index 70539571ca0..936339b2596 100644 --- a/src/graphics/texture.js +++ b/src/graphics/texture.js @@ -974,19 +974,19 @@ class Texture { const mipSize = this._levels[idx].length; if (!mipSize) { Debug.error(`No byte array for mip ${idx}`); - return; + return undefined; } fsize += mipSize; } else { for (let face = 0; face < 6; face++) { if (!this._levels[idx][face]) { Debug.error(`No level data for mip ${idx}, face ${face}`); - return; + return undefined; } const mipSize = this._levels[idx][face].length; if (!mipSize) { Debug.error(`No byte array for mip ${idx}, face ${face}`); - return; + return undefined; } fsize += mipSize; } diff --git a/src/resources/loader.js b/src/resources/loader.js index 9226612818f..63dcd142fee 100644 --- a/src/resources/loader.js +++ b/src/resources/loader.js @@ -265,6 +265,7 @@ class ResourceLoader { if (this._cache[url + type]) { return this._cache[url + type]; } + return undefined; } /** diff --git a/src/resources/texture.js b/src/resources/texture.js index 1be94477bde..e036430121e 100644 --- a/src/resources/texture.js +++ b/src/resources/texture.js @@ -226,7 +226,7 @@ class TextureHandler { open(url, data, asset) { if (!url) - return; + return undefined; let texture = this._getParser(url).open(url, data, this._device); diff --git a/src/scene/batching/batch-manager.js b/src/scene/batching/batch-manager.js index bfef611f49b..8ab1d8ec21b 100644 --- a/src/scene/batching/batch-manager.js +++ b/src/scene/batching/batch-manager.js @@ -142,8 +142,8 @@ class BatchManager { } if (this._batchGroups[id]) { - Debug.error(`batch group with id ${id} already exists`); - return; + Debug.error(`Batch group with id ${id} already exists.`); + return undefined; } const group = new BatchGroup(id, name, dynamic, maxAabbSize, layers); @@ -160,7 +160,7 @@ class BatchManager { */ removeGroup(id) { if (!this._batchGroups[id]) { - Debug.error(`batch group with id ${id} doesn't exist`); + Debug.error(`Batch group with id ${id} doesn't exist.`); return; } diff --git a/src/scene/materials/standard-material-options-builder.js b/src/scene/materials/standard-material-options-builder.js index d09d1d54a6c..de62571e55c 100644 --- a/src/scene/materials/standard-material-options-builder.js +++ b/src/scene/materials/standard-material-options-builder.js @@ -297,7 +297,7 @@ class StandardMaterialOptionsBuilder { const isOpacity = p === "opacity"; if (isOpacity && stdMat.blendType === BLEND_NONE && stdMat.alphaTest === 0.0 && !stdMat.alphaToCoverage) - return options; + return; if (!minimalOptions || isOpacity) { if (p !== "height" && stdMat[vname]) { diff --git a/src/vr/vr-display.js b/src/vr/vr-display.js index 4e4fa7ff4cd..026846cc9dd 100644 --- a/src/vr/vr-display.js +++ b/src/vr/vr-display.js @@ -353,6 +353,7 @@ class VrDisplay extends EventHandler { */ getFrameData() { if (this.display) return this._frameData; + return undefined; } /**