Skip to content

Commit 28a7345

Browse files
marklundinCopilot
andauthored
Deprecate Internal Scripts (#193)
* Enhance script definitions with static scriptName property - Added static scriptName properties to various scripts including Rotator, AutoRotator, Grid, ShadowCatcher, and OrbitCamera classes for improved identification. - Marked Grid and ShadowCatcher scripts as deprecated, recommending alternative implementations from the PlayCanvas library. - Updated documentation comments to guide users on migration to the new script structure. * Deprecate Grid and ShadowCatcher scripts with warning messages - Added deprecation warnings to the Grid and ShadowCatcher scripts, advising users to transition to the respective implementations from the PlayCanvas library. - Imported the `warnOnce` utility to facilitate the warning mechanism in both scripts. * Deprecate Grid and ShadowCatcher scripts - Added a changeset to mark the Grid and ShadowCatcher scripts as deprecated, indicating they will be removed in the next major release. This follows previous warnings and encourages users to transition to alternative implementations from the PlayCanvas library. * Update .changeset/better-mice-marry.md Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 931eac0 commit 28a7345

File tree

6 files changed

+42
-3
lines changed

6 files changed

+42
-3
lines changed

.changeset/better-mice-marry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@playcanvas/react": patch
3+
---
4+
5+
Deprecated Grid and ShadowCatcher scripts. These will be removed in the next major release

packages/lib/src/components/Script.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { SubclassOf } from "../utils/types-utils.ts";
1515
* @example
1616
* // A Rotator script that rotates the entity around the Y axis
1717
* class Rotator extends Script {
18+
* static scriptName = 'rotator';
19+
*
1820
* update(dt: number) {
1921
* this.entity.rotate(0, 1, 0, dt);
2022
* }

packages/lib/src/scripts/auto-rotator/auto-rotator.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const smoothStep = (x: number): number =>
55

66

77
class AutoRotator extends Script {
8+
static scriptName = 'autoRotator';
9+
810
speed: number = 4;
911
pitchSpeed: number = 0;
1012
pitchAmount: number = 1;

packages/lib/src/scripts/infinite-grid/infinite-grid.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
BLENDMODE_SRC_ALPHA,
1414
BLENDEQUATION_ADD
1515
} from 'playcanvas';
16+
import { warnOnce } from '../../utils/validation.ts';
1617

1718
const vsCode = /* glsl*/ `
1819
uniform mat4 camera_matrix;
@@ -178,10 +179,24 @@ const attributes = {
178179
vertex_position: SEMANTIC_POSITION
179180
};
180181

182+
/**
183+
* @deprecated This script is deprecated and will be removed in the next major version.
184+
*
185+
* Use {@link https://github.com/playcanvas/engine/tree/main/scripts/esm/grid.mjs | Grid} from `playcanvas` instead.
186+
*
187+
* ```tsx
188+
* import { Grid } from "playcanvas/scripts/esm/grid.mjs";
189+
*
190+
* export const MyScript = () => <Script script={Grid} />;
191+
* ```
192+
*/
181193
export class Grid extends Script {
194+
static scriptName = 'grid';
182195

183196
initialize() {
184197

198+
warnOnce('This script is deprecated and will be removed in the next major version. Use the `Grid` from `playcanvas` instead.');
199+
185200
const layerName = 'World';
186201

187202
const device = this.app.graphicsDevice;

packages/lib/src/scripts/orbit-controls/orbit-camera.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
} from 'playcanvas';
66

77
export class OrbitCamera extends Script {
8-
static __name = 'orbitCamera';
8+
static scriptName = 'orbitCamera';
99

1010
/**
1111
* @attribute
@@ -443,7 +443,7 @@ export class OrbitCamera extends Script {
443443

444444

445445
export class OrbitCameraInputMouse extends Script {
446-
static __name = 'orbitCameraInputMouse';
446+
static scriptName = 'orbitCameraInputMouse';
447447

448448
/**
449449
* How fast the camera moves around the orbit. Higher is faster
@@ -574,7 +574,7 @@ export class OrbitCameraInputMouse extends Script {
574574
}
575575

576576
export class OrbitCameraInputTouch extends Script {
577-
static __name = 'orbitCameraInputTouch';
577+
static scriptName = 'orbitCameraInputTouch';
578578

579579
/**
580580
* How fast the camera moves around the orbit. Higher is faster

packages/lib/src/scripts/shadow-catcher/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
import { Script, Entity, Layer, StandardMaterial, BLEND_NORMAL, SHADOW_VSM16, SHADOWUPDATE_REALTIME, CHUNKAPI_2_1 } from 'playcanvas';
2+
import { warnOnce } from '../../utils/validation.ts';
23

34
const endPS = `
45
litArgs_opacity = mix(light0_shadowIntensity, 0.0, shadow0);
56
gl_FragColor.rgb = vec3(0.0);
67
`;
78

9+
/**
10+
* @deprecated This script is deprecated and will be removed in the next major version.
11+
*
12+
* Use {@link https://github.com/playcanvas/engine/tree/main/scripts/esm/shadow-catcher.mjs | ShadowCatcher} from `playcanvas` instead.
13+
*
14+
* ```tsx
15+
* import { ShadowCatcher } from "playcanvas/scripts/esm/shadow-catcher.mjs";
16+
*
17+
* export const MyScript = () => <Script script={ShadowCatcher} />;
18+
* ```
19+
*/
820
export class ShadowCatcher extends Script {
21+
static scriptName = 'shadowCatcher';
922
/**
1023
* The shadow distance of the shadow catcher light.
1124
* @type {number}
@@ -43,6 +56,8 @@ export class ShadowCatcher extends Script {
4356
light = null;
4457

4558
initialize() {
59+
warnOnce('This script is deprecated and will be removed in the next major version. Use the `ShadowCatcher` from `playcanvas` instead.');
60+
4661
// create and add the shadow layer
4762
this.layer = new Layer({
4863
name: 'Shadow Layer'

0 commit comments

Comments
 (0)