Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/assets/scripts/annotation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {
* - An annotation panel that shows title and description text.
*/
export class Annotation extends Script {
static scriptName = 'annotation';

/** @type {HTMLDivElement | null} */
static _activeTooltip = null;

Expand Down
2 changes: 2 additions & 0 deletions examples/assets/scripts/camera-feed.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Script } from 'playcanvas';
* It then streams the camera's video to the video element and plays it.
*/
export class CameraFeed extends Script {
static scriptName = 'cameraFeed';

/**
* Whether to flip the video stream horizontally to behave like a mirror.
*
Expand Down
2 changes: 2 additions & 0 deletions examples/assets/scripts/choose-color.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { math, Script, Color } from 'playcanvas';

export class ChooseColor extends Script {
static scriptName = 'chooseColor';

// Define available colors as a static property
static PAINT_OPTIONS = [
{ name: 'Guards Red', color: new Color(0.902, 0.004, 0.086), metallic: false },
Expand Down
2 changes: 2 additions & 0 deletions examples/assets/scripts/face-detection.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { FaceLandmarker, FilesetResolver } from '@mediapipe/tasks-vision';
import { Mat4, Script } from 'playcanvas';

export class FaceDetection extends Script {
static scriptName = 'faceDetection';

/**
* @type {FaceLandmarker}
* @private
Expand Down
2 changes: 2 additions & 0 deletions examples/assets/scripts/falling-blocks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Script, Entity, KEY_LEFT, KEY_RIGHT, KEY_UP, KEY_DOWN, KEY_SPACE, KEY_P

// Falling Blocks Game Controller
export class FallingBlocksGame extends Script {
static scriptName = 'fallingBlocksGame';

// Attributes
boardWidth = 10;

Expand Down
2 changes: 2 additions & 0 deletions examples/assets/scripts/follow-pointer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Script } from 'playcanvas';
*/

export class FollowPointer extends Script {
static scriptName = 'followPointer';

initialize() {
const canvas = this.app.graphicsDevice.canvas;
canvas.addEventListener('pointermove', (event) => {
Expand Down
2 changes: 2 additions & 0 deletions examples/assets/scripts/gravity.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Script } from 'playcanvas';

export class Gravity extends Script {
static scriptName = 'gravity';

update(dt) {
const { x, y, z } = this.entity.getPosition();
this.entity.rigidbody.applyForce(-x, -y, -z);
Expand Down
2 changes: 2 additions & 0 deletions examples/assets/scripts/hand-gestures.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { HandLandmarker, GestureRecognizer, FilesetResolver } from '@mediapipe/t
import { Script, Vec3 } from 'playcanvas';

export class HandGestureController extends Script {
static scriptName = 'handGestureController';

/**
* Maximum number of hands to detect
* @type {number}
Expand Down
2 changes: 2 additions & 0 deletions examples/assets/scripts/morph-update.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Script } from 'playcanvas';

export class MorphUpdate extends Script {
static scriptName = 'morphUpdate';

initialize() {
this.app.on('face:blendshapes', (categories) => {
const renders = this.entity.findComponents('render');
Expand Down
2 changes: 2 additions & 0 deletions examples/assets/scripts/orbit.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Script } from 'playcanvas';

export class Orbit extends Script {
static scriptName = 'orbit';

radius = 4;

speed = 0.4;
Expand Down
2 changes: 2 additions & 0 deletions examples/assets/scripts/rotate.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Script } from 'playcanvas';

export class Rotate extends Script {
static scriptName = 'rotate';

update(dt) {
this.entity.rotate(10 * dt, 20 * dt, 30 * dt);
}
Expand Down
2 changes: 2 additions & 0 deletions examples/assets/scripts/scroll.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Script } from 'playcanvas';

export class Scroll extends Script {
static scriptName = 'scroll';

update(dt) {
this.entity.translateLocal(0, dt * 0.5, 0);
}
Expand Down
4 changes: 4 additions & 0 deletions examples/assets/scripts/solar-system.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Script, Vec3 } from 'playcanvas';

export class PlanetaryCamera extends Script {
static scriptName = 'planetaryCamera';

initialize() {
// Camera offsets: X is sunward offset, Y and Z provide viewing angle
this.cameraOffsets = new Map([
Expand Down Expand Up @@ -70,6 +72,8 @@ export class PlanetaryCamera extends Script {
}

export class PlanetaryMotion extends Script {
static scriptName = 'planetaryMotion';

initialize() {
// Planet radii (for scale reference)
this.planetSizes = new Map([
Expand Down
2 changes: 2 additions & 0 deletions examples/assets/scripts/static-body.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Script } from 'playcanvas';

export class StaticBody extends Script {
static scriptName = 'staticBody';

initialize() {
this.entity.findComponents('render').forEach((render) => {
const entity = render.entity;
Expand Down
2 changes: 2 additions & 0 deletions examples/assets/scripts/text3d.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ class Polygon {
}

export class Text3D extends Script {
static scriptName = 'text3d';

/**
* TTF file used as the basis for this 3D text.
* @type {Asset}
Expand Down
2 changes: 2 additions & 0 deletions examples/assets/scripts/tweener.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ class TweenDescriptor { /* eslint-disable-line no-unused-vars */
}

export class Tweener extends Script {
static scriptName = 'tweener';

/**
* Array of tween configurations
* @type {TweenDescriptor[]}
Expand Down
2 changes: 2 additions & 0 deletions examples/assets/scripts/video-recorder-ui.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Script } from 'playcanvas';

export class VideoRecorderUI extends Script {
static scriptName = 'videoRecorderUI';

initialize() {
this.createUI();
// Listen to video recording progress events
Expand Down
2 changes: 2 additions & 0 deletions examples/assets/scripts/video-recorder.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const FrameRate = {
};

export class VideoRecorder extends Script {
static scriptName = 'videoRecorder';

/**
* Whether to activate the recorder on initialization.
*
Expand Down
2 changes: 2 additions & 0 deletions examples/assets/scripts/video-texture.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Color, Script, Texture, PIXELFORMAT_R8_G8_B8, FILTER_LINEAR_MIPMAP_LINEAR, FILTER_LINEAR, ADDRESS_CLAMP_TO_EDGE } from 'playcanvas';

export class VideoTexture extends Script {
static scriptName = 'videoTexture';

/**
* URL to use if there is no video asset selected.
* @type {string}
Expand Down
2 changes: 1 addition & 1 deletion examples/text3d.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<!-- Text -->
<pc-entity name="3d text">
<pc-scripts>
<pc-script name="text3D" attributes='{
<pc-script name="text3d" attributes='{
"font": "asset:arial",
"text": "3D Text",
"thickness": 0.2
Expand Down