Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BREAKING] Remove support for legacy scripts #6584

Merged
merged 3 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
109 changes: 20 additions & 89 deletions src/framework/app-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,6 @@ class AppBase extends EventHandler {
*/
this.renderNextFrame = false;

/**
* Enable if you want entity type script attributes to not be re-mapped when an entity is
* cloned.
*
* @type {boolean}
* @ignore
*/
this.useLegacyScriptAttributeCloning = script.legacy;

this._librariesLoaded = false;
this._fillMode = FILLMODE_KEEP_ASPECT;
this._resolutionMode = RESOLUTION_FIXED;
Expand Down Expand Up @@ -767,43 +758,7 @@ class AppBase extends EventHandler {
}

_preloadScripts(sceneData, callback) {
if (!script.legacy) {
callback();
return;
}

this.systems.script.preloading = true;

const scripts = this._getScriptReferences(sceneData);

const l = scripts.length;
const progress = new Progress(l);
const regex = /^http(s)?:\/\//;

if (l) {
const onLoad = (err, ScriptType) => {
if (err)
console.error(err);

progress.inc();
if (progress.done()) {
this.systems.script.preloading = false;
callback();
}
};

for (let i = 0; i < l; i++) {
let scriptUrl = scripts[i];
// support absolute URLs (for now)
if (!regex.test(scriptUrl.toLowerCase()) && this._scriptPrefix)
scriptUrl = path.join(this._scriptPrefix, scripts[i]);

this.loader.load(scriptUrl, 'script', onLoad);
}
} else {
this.systems.script.preloading = false;
callback();
}
callback();
}

// set application properties from data file
Expand Down Expand Up @@ -942,52 +897,32 @@ class AppBase extends EventHandler {
const scriptsIndex = {};
const bundlesIndex = {};

if (!script.legacy) {
// add scripts in order of loading first
for (let i = 0; i < this.scriptsOrder.length; i++) {
const id = this.scriptsOrder[i];
if (!assets[id])
continue;

scriptsIndex[id] = true;
list.push(assets[id]);
}
// add scripts in order of loading first
for (let i = 0; i < this.scriptsOrder.length; i++) {
const id = this.scriptsOrder[i];
if (!assets[id])
continue;

// then add bundles
if (this.enableBundles) {
for (const id in assets) {
if (assets[id].type === 'bundle') {
bundlesIndex[id] = true;
list.push(assets[id]);
}
}
}
scriptsIndex[id] = true;
list.push(assets[id]);
}

// then add rest of assets
// then add bundles
if (this.enableBundles) {
for (const id in assets) {
if (scriptsIndex[id] || bundlesIndex[id])
continue;

list.push(assets[id]);
}
} else {
if (this.enableBundles) {
// add bundles
for (const id in assets) {
if (assets[id].type === 'bundle') {
bundlesIndex[id] = true;
list.push(assets[id]);
}
if (assets[id].type === 'bundle') {
bundlesIndex[id] = true;
list.push(assets[id]);
}
}
}

// then add rest of assets
for (const id in assets) {
if (bundlesIndex[id])
continue;
// then add rest of assets
for (const id in assets) {
if (scriptsIndex[id] || bundlesIndex[id])
continue;

list.push(assets[id]);
}
list.push(assets[id]);
}

for (let i = 0; i < list.length; i++) {
Expand Down Expand Up @@ -1132,10 +1067,6 @@ class AppBase extends EventHandler {
this.stats.frame.updateStart = now();
// #endif

// Perform ComponentSystem update
if (script.legacy)
this.systems.fire('fixedUpdate', 1.0 / 60.0);

this.systems.fire(this._inTools ? 'toolsUpdate' : 'update', dt);
this.systems.fire('animationUpdate', dt);
this.systems.fire('postUpdate', dt);
Expand Down
4 changes: 1 addition & 3 deletions src/framework/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { BatchManager } from '../scene/batching/batch-manager.js';

import { AppBase } from './app-base.js';
import { AppOptions } from './app-options.js';
import { script } from './script.js';
import { AnimationComponentSystem } from './components/animation/system.js';
import { AnimComponentSystem } from './components/anim/system.js';
import { AudioListenerComponentSystem } from './components/audio-listener/system.js';
Expand All @@ -25,7 +24,6 @@ import { ParticleSystemComponentSystem } from './components/particle-system/syst
import { RenderComponentSystem } from './components/render/system.js';
import { RigidBodyComponentSystem } from './components/rigid-body/system.js';
import { ScreenComponentSystem } from './components/screen/system.js';
import { ScriptLegacyComponentSystem } from './components/script-legacy/system.js';
import { ScrollViewComponentSystem } from './components/scroll-view/system.js';
import { ScrollbarComponentSystem } from './components/scrollbar/system.js';
import { SoundComponentSystem } from './components/sound/system.js';
Expand Down Expand Up @@ -170,7 +168,7 @@ class Application extends AppBase {
RenderComponentSystem,
CameraComponentSystem,
LightComponentSystem,
script.legacy ? ScriptLegacyComponentSystem : ScriptComponentSystem,
ScriptComponentSystem,
AudioSourceComponentSystem,
SoundComponentSystem,
AudioListenerComponentSystem,
Expand Down
4 changes: 1 addition & 3 deletions src/framework/asset/asset-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { TagsCache } from '../../core/tags-cache.js';

import { standardMaterialTextureParameters } from '../../scene/materials/standard-material-parameters.js';

import { script } from '../script.js';

import { Asset } from './asset.js';

/**
Expand Down Expand Up @@ -438,7 +436,7 @@ class AssetRegistry extends EventHandler {
this.fire('error:' + asset.id, err, asset);
asset.fire('error', err, asset);
} else {
if (!script.legacy && asset.type === 'script') {
if (asset.type === 'script') {
const handler = this._loader.getHandler('script');
if (handler._cache[asset.id] && handler._cache[asset.id].parentNode === document.head) {
// remove old element
Expand Down
210 changes: 0 additions & 210 deletions src/framework/components/script-legacy/component.js

This file was deleted.

Loading