-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
scene.js
46 lines (36 loc) · 1.12 KB
/
scene.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { SceneUtils } from './scene-utils.js';
import { SceneParser } from '../parsers/scene.js';
import { ResourceHandler } from './handler.js';
/**
* Resource handler used for loading {@link Scene} resources.
*
* @category Graphics
*/
class SceneHandler extends ResourceHandler {
/**
* Create a new SceneHandler instance.
*
* @param {import('../app-base.js').AppBase} app - The running {@link AppBase}.
* @ignore
*/
constructor(app) {
super(app, 'scene');
}
load(url, callback) {
SceneUtils.load(url, this.maxRetries, callback);
}
open(url, data) {
// prevent script initialization until entire scene is open
this._app.systems.script.preloading = true;
const parser = new SceneParser(this._app, false);
const parent = parser.parse(data);
// set scene root
const scene = this._app.scene;
scene.root = parent;
this._app.applySceneSettings(data.settings);
// re-enable script initialization
this._app.systems.script.preloading = false;
return scene;
}
}
export { SceneHandler };