@needle-tools/engine 4.3.2-beta.3 → 4.3.2-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/gltf-progressive.js +91 -90
- package/dist/gltf-progressive.light.js +91 -90
- package/dist/gltf-progressive.light.min.js +6 -6
- package/dist/gltf-progressive.light.umd.cjs +4 -4
- package/dist/gltf-progressive.min.js +6 -6
- package/dist/gltf-progressive.umd.cjs +4 -4
- package/dist/needle-engine.bundle.js +2997 -2988
- package/dist/needle-engine.bundle.light.js +3036 -3027
- package/dist/needle-engine.bundle.light.min.js +110 -110
- package/dist/needle-engine.bundle.light.umd.cjs +94 -94
- package/dist/needle-engine.bundle.min.js +110 -110
- package/dist/needle-engine.bundle.umd.cjs +97 -97
- package/dist/needle-engine.light.d.ts +9 -9
- package/lib/engine/engine_context.d.ts +1 -0
- package/lib/engine/engine_context.js +3 -0
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_context_registry.js +7 -0
- package/lib/engine/engine_context_registry.js.map +1 -1
- package/lib/engine/engine_utils_format.js +5 -1
- package/lib/engine/engine_utils_format.js.map +1 -1
- package/lib/engine-components/Skybox.js +9 -8
- package/lib/engine-components/Skybox.js.map +1 -1
- package/package.json +2 -2
- package/plugins/common/license.js +42 -32
- package/src/engine/engine_context.ts +4 -0
- package/src/engine/engine_context_registry.ts +5 -0
- package/src/engine/engine_utils_format.ts +5 -1
- package/src/engine-components/Skybox.ts +8 -7
|
@@ -189,6 +189,10 @@ export class Context implements IContext {
|
|
|
189
189
|
ContextRegistry.Current = context;
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
static get All(): Context[] {
|
|
193
|
+
return ContextRegistry.All as Context[];
|
|
194
|
+
}
|
|
195
|
+
|
|
192
196
|
/** The name of the context */
|
|
193
197
|
name: string;
|
|
194
198
|
/** An alias for the context */
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type IComponent, type IContext, type LoadedModel } from "./engine_types.js";
|
|
2
2
|
|
|
3
|
+
const debug = typeof window !== undefined ? window.location.search.includes("debugcontext") : false;
|
|
4
|
+
|
|
3
5
|
/** The various events that can be dispatched by a Needle Engine {@link IContext} instance
|
|
4
6
|
*/
|
|
5
7
|
export enum ContextEvent {
|
|
@@ -62,6 +64,8 @@ export class ContextRegistry {
|
|
|
62
64
|
|
|
63
65
|
/** @internal Internal use only */
|
|
64
66
|
static register(ctx: IContext) {
|
|
67
|
+
if (this.Registered.indexOf(ctx) !== -1) return;
|
|
68
|
+
if (debug) console.warn("Registering context");
|
|
65
69
|
this.Registered.push(ctx);
|
|
66
70
|
this.dispatchCallback(ContextEvent.ContextRegistered, ctx);
|
|
67
71
|
}
|
|
@@ -70,6 +74,7 @@ export class ContextRegistry {
|
|
|
70
74
|
static unregister(ctx: IContext) {
|
|
71
75
|
const index = this.Registered.indexOf(ctx);
|
|
72
76
|
if (index === -1) return;
|
|
77
|
+
if (debug) console.warn("Unregistering context");
|
|
73
78
|
this.Registered.splice(index, 1);
|
|
74
79
|
}
|
|
75
80
|
|
|
@@ -61,7 +61,11 @@ export async function tryDetermineFileTypeFromURL(url: string, useExtension: boo
|
|
|
61
61
|
|
|
62
62
|
// If the URL doesnt contain a filetype we need to check the header
|
|
63
63
|
// This is the case for example if we load a file from a data url
|
|
64
|
-
const
|
|
64
|
+
const newUrl = new URL(url);
|
|
65
|
+
// Adding a URL parameter to avoid the brower to bust the full cache
|
|
66
|
+
// If we don't do this the file that might already be disc cached will be deleted from the cache
|
|
67
|
+
newUrl.searchParams.append("range", "true");
|
|
68
|
+
const header = await fetch(newUrl, {
|
|
65
69
|
method: "GET",
|
|
66
70
|
headers: {
|
|
67
71
|
"range": "bytes=0-32"
|
|
@@ -5,7 +5,7 @@ import { KTX2Loader } from "three/examples/jsm/loaders/KTX2Loader.js";
|
|
|
5
5
|
import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader.js';
|
|
6
6
|
|
|
7
7
|
import { disposeObjectResources, setDisposable } from "../engine/engine_assetdatabase.js";
|
|
8
|
-
import { ContextRegistry } from "../engine/engine_context_registry.js";
|
|
8
|
+
import { ContextEvent, ContextRegistry } from "../engine/engine_context_registry.js";
|
|
9
9
|
import { registerObservableAttribute } from "../engine/engine_element_extras.js";
|
|
10
10
|
import { syncField } from "../engine/engine_networking_auto.js";
|
|
11
11
|
import { serializable } from "../engine/engine_serialization_decorator.js";
|
|
@@ -39,11 +39,11 @@ function createRemoteSkyboxComponent(context: IContext, url: string, skybox: boo
|
|
|
39
39
|
return remote.setSkybox(url);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
const promises = new Array<Promise<any>>();
|
|
43
|
+
ContextRegistry.registerCallback(ContextEvent.ContextCreationStart, (args) => {
|
|
43
44
|
const context = args.context;
|
|
44
45
|
const skyboxImage = context.domElement.getAttribute("skybox-image") || context.domElement.getAttribute("background-image");
|
|
45
46
|
const environmentImage = context.domElement.getAttribute("environment-image");
|
|
46
|
-
const promises = new Array<Promise<any>>();
|
|
47
47
|
if (skyboxImage) {
|
|
48
48
|
if (debug)
|
|
49
49
|
console.log("Creating remote skybox to load " + skyboxImage);
|
|
@@ -60,10 +60,11 @@ ContextRegistry.addContextCreatedCallback((args) => {
|
|
|
60
60
|
const promise = createRemoteSkyboxComponent(context, environmentImage, false, true, "environment-image");
|
|
61
61
|
promises.push(promise);
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
});
|
|
64
|
+
ContextRegistry.registerCallback(ContextEvent.ContextCreationStart, () => {
|
|
65
|
+
return Promise.all(promises).finally(() => {
|
|
66
|
+
promises.length = 0;
|
|
67
|
+
})
|
|
67
68
|
});
|
|
68
69
|
|
|
69
70
|
declare type SkyboxCacheEntry = { src: string, texture: Promise<Texture> };
|