Skip to content

Commit

Permalink
[BREAKING] Removed backwards compatibility for few functions (#6408)
Browse files Browse the repository at this point in the history
* [BREAKING] Removed backwards compatibility for few functions

* lint

---------

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
  • Loading branch information
mvaligursky and Martin Valigursky authored May 23, 2024
1 parent 6a5cd67 commit aeebcdc
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 135 deletions.
24 changes: 0 additions & 24 deletions src/framework/components/anim/component-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,30 +312,6 @@ class AnimComponentLayer {
this._blendTimeElapsed = 0;
}

/**
* Add a mask to this layer.
*
* @param {object} [mask] - The mask to assign to the layer. If not provided the current mask
* in the layer will be removed.
* @example
* entity.anim.baseLayer.assignMask({
* // include the spine of the current model and all of its children
* "path/to/spine": {
* children: true
* },
* // include the hip of the current model but not all of its children
* "path/to/hip": true
* });
* @ignore
*/
assignMask(mask) {
Debug.deprecated('The pc.AnimComponentLayer#assignMask function is now deprecated. Assign masks to the pc.AnimComponentLayer#mask property instead.');
if (this._controller.assignMask(mask)) {
this._component.rebind();
}
this._mask = mask;
}

/**
* Assigns an animation track to a state or blend tree node in the current graph. If a state
* for the given nodePath doesn't exist, it will be created. If all states nodes are linked and
Expand Down
16 changes: 1 addition & 15 deletions src/framework/graphics/picker.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { Color } from '../../core/math/color.js';

import { ADDRESS_CLAMP_TO_EDGE, FILTER_NEAREST, PIXELFORMAT_RGBA8 } from '../../platform/graphics/constants.js';
import { GraphicsDevice } from '../../platform/graphics/graphics-device.js';
import { RenderTarget } from '../../platform/graphics/render-target.js';
import { Texture } from '../../platform/graphics/texture.js';

import { Camera } from '../../scene/camera.js';
import { Layer } from '../../scene/layer.js';

import { getApplication } from '../globals.js';
import { Debug } from '../../core/debug.js';
import { RenderPassPicker } from './render-pass-picker.js';
import { math } from '../../core/math/math.js';
Expand Down Expand Up @@ -46,10 +43,7 @@ class Picker {
* @param {number} height - The height of the pick buffer in pixels.
*/
constructor(app, width, height) {
if (app instanceof GraphicsDevice) {
app = getApplication();
Debug.deprecated('pc.Picker now takes pc.AppBase as first argument. Passing pc.GraphicsDevice is deprecated.');
}
Debug.assert(app);

// Note: The only reason this class needs the app is to access the renderer. Ideally we remove this dependency and move
// the Picker from framework to the scene level, or even the extras.
Expand Down Expand Up @@ -235,14 +229,6 @@ class Picker {
*/
prepare(camera, scene, layers) {

// handle deprecated arguments
if (camera instanceof Camera) {
Debug.deprecated('pc.Picker#prepare now takes pc.CameraComponent as first argument. Passing pc.Camera is deprecated.');

// Get the camera component
camera = camera.node.camera;
}

if (layers instanceof Layer) {
layers = [layers];
}
Expand Down
21 changes: 4 additions & 17 deletions src/platform/graphics/render-target.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,13 @@ class RenderTarget {
* camera.renderTarget = null;
*/
constructor(options = {}) {
Debug.assert(!(options instanceof GraphicsDevice), 'pc.RenderTarget constructor no longer accepts GraphicsDevice parameter.');
this.id = id++;

const _arg2 = arguments[1];
const _arg3 = arguments[2];

if (options instanceof GraphicsDevice) {
// old constructor
this._colorBuffer = _arg2;
options = _arg3;

Debug.deprecated('pc.RenderTarget constructor no longer accepts GraphicsDevice parameter.');

} else {
// new constructor
this._colorBuffer = options.colorBuffer;
}

// Use the single colorBuffer in the colorBuffers array. This allows us to always just use the array internally.
if (this._colorBuffer) {
this._colorBuffers = [this._colorBuffer];
this._colorBuffer = options.colorBuffer;
if (options.colorBuffer) {
this._colorBuffers = [options.colorBuffer];
}

// Process optional arguments
Expand Down
15 changes: 4 additions & 11 deletions src/platform/graphics/texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
TEXHINT_SHADOWMAP, TEXHINT_ASSET, TEXHINT_LIGHTMAP,
TEXTURELOCK_WRITE,
TEXTUREPROJECTION_NONE, TEXTUREPROJECTION_CUBE,
TEXTURETYPE_DEFAULT, TEXTURETYPE_RGBM, TEXTURETYPE_RGBE, TEXTURETYPE_RGBP, TEXTURETYPE_SWIZZLEGGGR,
TEXTURETYPE_DEFAULT, TEXTURETYPE_RGBM, TEXTURETYPE_RGBE, TEXTURETYPE_RGBP,
isIntegerPixelFormat, FILTER_NEAREST, TEXTURELOCK_NONE, TEXTURELOCK_READ
} from './constants.js';

Expand Down Expand Up @@ -247,16 +247,9 @@ class Texture {
this._compareOnRead = options.compareOnRead ?? false;
this._compareFunc = options.compareFunc ?? FUNC_LESS;

this.type = TEXTURETYPE_DEFAULT;
if (options.hasOwnProperty('type')) {
this.type = options.type;
} else if (options.hasOwnProperty('rgbm')) {
Debug.deprecated("options.rgbm is deprecated. Use options.type instead.");
this.type = options.rgbm ? TEXTURETYPE_RGBM : TEXTURETYPE_DEFAULT;
} else if (options.hasOwnProperty('swizzleGGGR')) {
Debug.deprecated("options.swizzleGGGR is deprecated. Use options.type instead.");
this.type = options.swizzleGGGR ? TEXTURETYPE_SWIZZLEGGGR : TEXTURETYPE_DEFAULT;
}
this.type = options.hasOwnProperty('type') ? options.type : TEXTURETYPE_DEFAULT;
Debug.assert(!options.hasOwnProperty('rgbm'), 'Use options.type.');
Debug.assert(!options.hasOwnProperty('swizzleGGGR'), 'Use options.type.');

this.projection = TEXTUREPROJECTION_NONE;
if (this._cubemap) {
Expand Down
16 changes: 4 additions & 12 deletions src/platform/graphics/vertex-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,10 @@ class VertexBuffer {
*/
constructor(graphicsDevice, format, numVertices, options) {

// By default, vertex buffers are static (better for performance since buffer data can be cached in VRAM)
let initialData;
if (typeof options === 'object') {

this.usage = options.usage ?? BUFFER_STATIC;
initialData = options.data;

} else if (arguments.length > 3) { // handle backwards compatibility
Debug.assert(arguments.length <= 4 && (!options || typeof options === 'object'), 'incorrect arguments');

Debug.deprecated('VertexBuffer: usage and initialData parameters are deprecated, use options object instead');
this.usage = arguments[3] ?? BUFFER_STATIC;
initialData = arguments[4];
}
// By default, vertex buffers are static (better for performance since buffer data can be cached in VRAM)
this.usage = options?.usage ?? BUFFER_STATIC;

this.device = graphicsDevice;
this.format = format;
Expand All @@ -57,6 +48,7 @@ class VertexBuffer {
this.adjustVramSizeTracking(graphicsDevice._vram, this.numBytes);

// Allocate the storage
const initialData = options?.data;
if (initialData) {
this.setData(initialData);
} else {
Expand Down
17 changes: 1 addition & 16 deletions src/scene/graphics/reproject-texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from '../../platform/graphics/constants.js';
import { DebugGraphics } from '../../platform/graphics/debug-graphics.js';
import { DeviceCache } from '../../platform/graphics/device-cache.js';
import { GraphicsDevice } from '../../platform/graphics/graphics-device.js';
import { RenderTarget } from '../../platform/graphics/render-target.js';
import { drawQuadWithShader } from './quad-render-utils.js';
import { Texture } from '../../platform/graphics/texture.js';
Expand Down Expand Up @@ -400,21 +399,7 @@ void main(void) {
* @category Graphics
*/
function reprojectTexture(source, target, options = {}) {
// maintain backwards compatibility with previous function signature
// reprojectTexture(device, source, target, specularPower = 1, numSamples = 1024)
if (source instanceof GraphicsDevice) {
source = arguments[1];
target = arguments[2];
options = { };
if (arguments[3] !== undefined) {
options.specularPower = arguments[3];
}
if (arguments[4] !== undefined) {
options.numSamples = arguments[4];
}

Debug.deprecated('please use the updated pc.reprojectTexture API.');
}
Debug.assert(source instanceof Texture && target instanceof Texture, 'source and target must be textures');

// calculate inner width and height
const seamPixels = options.seamPixels ?? 0;
Expand Down
7 changes: 1 addition & 6 deletions src/scene/morph-target.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ class MorphTarget {
* allowing the clone operation.
*/
constructor(options) {

if (arguments.length === 2) {
Debug.deprecated('Passing graphicsDevice to MorphTarget is deprecated, please remove the parameter.');
options = arguments[1];
}

Debug.assert(arguments.length === 1);
this.options = options;
this._name = options.name;
this._defaultWeight = options.defaultWeight || 0;
Expand Down
2 changes: 0 additions & 2 deletions src/scene/shader-lib/chunks/chunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ import TBNPS from './lit/frag/TBN.js';
import TBNderivativePS from './lit/frag/TBNderivative.js';
import TBNfastPS from './lit/frag/TBNfast.js';
import TBNObjectSpacePS from './lit/frag/TBNObjectSpace.js';
import textureSamplePS from './standard/frag/textureSample.js';
import thicknessPS from './standard/frag/thickness.js';
import tonemappingAcesPS from './common/frag/tonemappingAces.js';
import tonemappingAces2PS from './common/frag/tonemappingAces2.js';
Expand Down Expand Up @@ -383,7 +382,6 @@ const shaderChunks = {
TBNderivativePS,
TBNfastPS,
TBNObjectSpacePS,
textureSamplePS,
thicknessPS,
tonemappingAcesPS,
tonemappingAces2PS,
Expand Down
25 changes: 0 additions & 25 deletions src/scene/shader-lib/chunks/standard/frag/textureSample.js

This file was deleted.

11 changes: 4 additions & 7 deletions src/scene/shader-lib/programs/standard.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,13 +487,10 @@ class ShaderGeneratorStandard extends ShaderGenerator {
}
}

// only add the legacy chunk if it's referenced
if (code.code.indexOf('texture2DSRGB') !== -1 ||
code.code.indexOf('texture2DRGBM') !== -1 ||
code.code.indexOf('texture2DRGBE') !== -1) {
Debug.deprecated('Shader chunk macro $texture2DSAMPLE(XXX) is deprecated. Please use $DECODE(texture2D(XXX)) instead.');
code.prepend(litShader.chunks.textureSamplePS);
}
Debug.assert(code.code.indexOf('texture2DSRGB') === -1 &&
code.code.indexOf('texture2DRGBM') === -1 &&
code.code.indexOf('texture2DRGBE') === -1, 'Shader chunk macro $texture2DSAMPLE(XXX) is deprecated. Please use $DECODE(texture2D(XXX)) instead.');

} else {
// all other passes require only opacity
const opacityShadowDither = options.litOptions.opacityShadowDither;
Expand Down

0 comments on commit aeebcdc

Please sign in to comment.