Skip to content

Commit

Permalink
Revert "Add Script alias (#6237)"
Browse files Browse the repository at this point in the history
This reverts commit dd65f24.
  • Loading branch information
marklundin committed May 13, 2024
1 parent cbd7160 commit ef63f56
Show file tree
Hide file tree
Showing 12 changed files with 578 additions and 584 deletions.
3 changes: 0 additions & 3 deletions src/deprecated/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ import { basisInitialize } from '../framework/handlers/basis.js';
import { LitShader } from '../scene/shader-lib/programs/lit-shader.js';
import { Geometry } from '../scene/geometry/geometry.js';

// ScriptType alias
export { Script as ScriptType } from '../framework/script/script.js';

// CORE
export const LINEBATCH_WORLD = 0;
export const LINEBATCH_OVERLAY = 1;
Expand Down
44 changes: 22 additions & 22 deletions src/framework/components/script/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Entity } from '../../entity.js';
*/
class ScriptComponent extends Component {
/**
* Fired when a {@link Script} instance is created and attached to the script component.
* Fired when a {@link ScriptType} instance is created and attached to the script component.
* This event is available in two forms. They are as follows:
*
* 1. `create` - Fired when a script instance is created. The name of the script type and the
Expand All @@ -40,7 +40,7 @@ class ScriptComponent extends Component {
static EVENT_CREATE = 'create';

/**
* Fired when a {@link Script} instance is destroyed and removed from the script component.
* Fired when a {@link ScriptType} instance is destroyed and removed from the script component.
* This event is available in two forms. They are as follows:
*
* 1. `destroy` - Fired when a script instance is destroyed. The name of the script type and
Expand Down Expand Up @@ -109,7 +109,7 @@ class ScriptComponent extends Component {
static EVENT_STATE = 'state';

/**
* Fired when the index of a {@link Script} instance is changed in the script component.
* Fired when the index of a {@link ScriptType} instance is changed in the script component.
* This event is available in two forms. They are as follows:
*
* 1. `move` - Fired when a script instance is moved. The name of the script type, the script
Expand All @@ -130,7 +130,7 @@ class ScriptComponent extends Component {
static EVENT_MOVE = 'move';

/**
* Fired when a {@link Script} instance had an exception. The handler is passed the script
* Fired when a {@link ScriptType} instance had an exception. The handler is passed the script
* instance, the exception and the method name that the exception originated from.
*
* @event
Expand All @@ -154,7 +154,7 @@ class ScriptComponent extends Component {
/**
* Holds all script instances for this component.
*
* @type {import('../../script/script.js').Script[]}
* @type {import('../../script/script-type.js').ScriptType[]}
* @private
*/
this._scripts = [];
Expand Down Expand Up @@ -191,7 +191,7 @@ class ScriptComponent extends Component {
* An array of all script instances attached to an entity. This array is read-only and should
* not be modified by developer.
*
* @type {import('../../script/script.js').Script[]}
* @type {import('../../script/script-type.js').ScriptType[]}
*/
set scripts(value) {
this._scriptsData = value;
Expand Down Expand Up @@ -546,8 +546,8 @@ class ScriptComponent extends Component {
/**
* Detect if script is attached to an entity.
*
* @param {string|typeof import('../../script/script.js').Script} nameOrType - The
* name or type of {@link Script}.
* @param {string|typeof import('../../script/script-type.js').ScriptType} nameOrType - The
* name or type of {@link ScriptType}.
* @returns {boolean} If script is attached to an entity.
* @example
* if (entity.script.has('playerController')) {
Expand All @@ -570,9 +570,9 @@ class ScriptComponent extends Component {
/**
* Get a script instance (if attached).
*
* @param {string|typeof import('../../script/script.js').Script} nameOrType - The
* name or type of {@link Script}.
* @returns {import('../../script/script.js').Script|null} If script is attached, the
* @param {string|typeof import('../../script/script-type.js').ScriptType} nameOrType - The
* name or type of {@link ScriptType}.
* @returns {import('../../script/script-type.js').ScriptType|null} If script is attached, the
* instance is returned. Otherwise null is returned.
* @example
* const controller = entity.script.get('playerController');
Expand All @@ -594,8 +594,8 @@ class ScriptComponent extends Component {
/**
* Create a script instance and attach to an entity script component.
*
* @param {string|typeof import('../../script/script.js').Script} nameOrType - The
* name or type of {@link Script}.
* @param {string|typeof import('../../script/script-type.js').ScriptType} nameOrType - The
* name or type of {@link ScriptType}.
* @param {object} [args] - Object with arguments for a script.
* @param {boolean} [args.enabled] - If script instance is enabled after creation. Defaults to
* true.
Expand All @@ -605,9 +605,9 @@ class ScriptComponent extends Component {
* script and attributes must be initialized manually. Defaults to false.
* @param {number} [args.ind] - The index where to insert the script instance at. Defaults to
* -1, which means append it at the end.
* @returns {import('../../script/script.js').Script|null} Returns an instance of a
* {@link Script} if successfully attached to an entity, or null if it failed because a
* script with a same name has already been added or if the {@link Script} cannot be found
* @returns {import('../../script/script-type.js').ScriptType|null} Returns an instance of a
* {@link ScriptType} if successfully attached to an entity, or null if it failed because a
* script with a same name has already been added or if the {@link ScriptType} cannot be found
* by name in the {@link ScriptRegistry}.
* @example
* entity.script.create('playerController', {
Expand Down Expand Up @@ -699,8 +699,8 @@ class ScriptComponent extends Component {
/**
* Destroy the script instance that is attached to an entity.
*
* @param {string|typeof import('../../script/script.js').Script} nameOrType - The
* name or type of {@link Script}.
* @param {string|typeof import('../../script/script-type.js').ScriptType} nameOrType - The
* name or type of {@link ScriptType}.
* @returns {boolean} If it was successfully destroyed.
* @example
* entity.script.destroy('playerController');
Expand Down Expand Up @@ -756,8 +756,8 @@ class ScriptComponent extends Component {
/**
* Swap the script instance.
*
* @param {string|typeof import('../../script/script.js').Script} nameOrType - The
* name or type of {@link Script}.
* @param {string|typeof import('../../script/script-type.js').ScriptType} nameOrType - The
* name or type of {@link ScriptType}.
* @returns {boolean} If it was successfully swapped.
* @private
*/
Expand Down Expand Up @@ -927,8 +927,8 @@ class ScriptComponent extends Component {
/**
* Move script instance to different position to alter update order of scripts within entity.
*
* @param {string|typeof import('../../script/script.js').Script} nameOrType - The
* name or type of {@link Script}.
* @param {string|typeof import('../../script/script-type.js').ScriptType} nameOrType - The
* name or type of {@link ScriptType}.
* @param {number} ind - New position index.
* @returns {boolean} If it was successfully moved.
* @example
Expand Down
8 changes: 4 additions & 4 deletions src/framework/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@ class Entity extends GraphNode {
/**
* Search the entity and all of its descendants for the first script instance of specified type.
*
* @param {string|typeof import('./script/script.js').Script} nameOrType - The name or type of {@link Script}.
* @returns {import('./script/script.js').Script|undefined} A script instance of specified type, if the entity or any of its descendants
* @param {string|typeof import('./script/script-type.js').ScriptType} nameOrType - The name or type of {@link ScriptType}.
* @returns {import('./script/script-type.js').ScriptType|undefined} A script instance of specified type, if the entity or any of its descendants
* has one. Returns undefined otherwise.
* @example
* // Get the first found "playerController" instance in the hierarchy tree that starts with this entity
Expand All @@ -415,8 +415,8 @@ class Entity extends GraphNode {
/**
* Search the entity and all of its descendants for all script instances of specified type.
*
* @param {string|typeof import('./script/script.js').Script} nameOrType - The name or type of {@link Script}.
* @returns {import('./script/script.js').Script[]} All script instances of specified type in the entity or any of its
* @param {string|typeof import('./script/script-type.js').ScriptType} nameOrType - The name or type of {@link ScriptType}.
* @returns {import('./script/script-type.js').ScriptType[]} All script instances of specified type in the entity or any of its
* descendants. Returns empty array if none found.
* @example
* // Get all "playerController" instances in the hierarchy tree that starts with this entity
Expand Down
6 changes: 3 additions & 3 deletions src/framework/handlers/script.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { platform } from '../../core/platform.js';
import { script } from '../script.js';
import { Script } from '../script/script.js';
import { ScriptType } from '../script/script-type.js';
import { ScriptTypes } from '../script/script-types.js';
import { registerScript } from '../script/script-create.js';
import { registerScript } from '../script/script.js';
import { ResourceLoader } from './loader.js';

import { ResourceHandler } from './handler.js';
Expand Down Expand Up @@ -154,7 +154,7 @@ class ScriptHandler extends ResourceHandler {

for (const key in module) {
const scriptClass = module[key];
const extendsScriptType = scriptClass.prototype instanceof Script;
const extendsScriptType = scriptClass.prototype instanceof ScriptType;

if (extendsScriptType) {

Expand Down
6 changes: 3 additions & 3 deletions src/framework/script/script-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,16 @@ function rawToValue(app, args, value, old) {

/**
* Container of Script Attribute definitions. Implements an interface to add/remove attributes and
* store their definition for a {@link Script}. Note: An instance of ScriptAttributes is
* created automatically by each {@link Script}.
* store their definition for a {@link ScriptType}. Note: An instance of ScriptAttributes is
* created automatically by each {@link ScriptType}.
*
* @category Script
*/
class ScriptAttributes {
/**
* Create a new ScriptAttributes instance.
*
* @param {typeof import('./script.js').Script} scriptType - Script Type that attributes relate to.
* @param {typeof import('./script-type.js').ScriptType} scriptType - Script Type that attributes relate to.
*/
constructor(scriptType) {
this.scriptType = scriptType;
Expand Down
148 changes: 0 additions & 148 deletions src/framework/script/script-create.js

This file was deleted.

Loading

0 comments on commit ef63f56

Please sign in to comment.