Skip to content

Commit

Permalink
[BREAKING] Remove support for legacy scripts (#6584)
Browse files Browse the repository at this point in the history
* [BREAKING] Remove support for legaxy scripts

* removed pc.script.attribute

---------

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
  • Loading branch information
2 people authored and marklundin committed Jun 6, 2024
1 parent c8885c8 commit f4352e1
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 1,043 deletions.
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 @@ -24,7 +23,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 @@ -169,7 +167,7 @@ class Application extends AppBase {
RenderComponentSystem,
CameraComponentSystem,
LightComponentSystem,
script.legacy ? ScriptLegacyComponentSystem : ScriptComponentSystem,
ScriptComponentSystem,
SoundComponentSystem,
AudioListenerComponentSystem,
ParticleSystemComponentSystem,
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

0 comments on commit f4352e1

Please sign in to comment.