@@ -127,7 +127,7 @@
|
|
127
127
|
returnMessageContainer(last as HTMLElement);
|
128
128
|
}
|
129
129
|
// truncate long messages before they go into the cache/set
|
130
|
-
if (msg.length >
|
130
|
+
if (msg.length > 400) msg = msg.substring(0, 400) + "...";
|
131
131
|
if (currentMessages.has(msg)) return;
|
132
132
|
currentMessages.add(msg);
|
133
133
|
const msgcontainer = getMessageContainer(type, msg);
|
@@ -14,6 +14,9 @@
|
|
14
14
|
export function showBalloonWarning(text: string): void {
|
15
15
|
showBalloonMessage(text, LogType.Warn);
|
16
16
|
}
|
17
|
+
export function showBalloonError(text: string): void {
|
18
|
+
showBalloonMessage(text, LogType.Error);
|
19
|
+
}
|
17
20
|
|
18
21
|
let _manuallySetDevEnvironment: boolean | undefined;
|
19
22
|
|
@@ -108,6 +108,11 @@
|
|
108
108
|
|
109
109
|
export function registerComponent(script: IComponent, context?: Context) {
|
110
110
|
if (!script) return;
|
111
|
+
if (!script.isComponent) {
|
112
|
+
if (isDevEnvironment() || debug)
|
113
|
+
console.error("Registered script is not a Needle Engine component. \nThe script will be ignored. Please make sure your component extends \"Behaviour\" imported from \"@needle-tools/engine\"\n", script);
|
114
|
+
return;
|
115
|
+
}
|
111
116
|
const new_scripts = context?.new_scripts ?? Context.Current.new_scripts;
|
112
117
|
if (!new_scripts.includes(script)) {
|
113
118
|
new_scripts.push(script);
|
@@ -46,6 +46,13 @@
|
|
46
46
|
for (let i = 0; i < new_scripts_buffer.length; i++) {
|
47
47
|
try {
|
48
48
|
const script: IComponent = new_scripts_buffer[i];
|
49
|
+
if (script.isComponent !== true) {
|
50
|
+
if (isDevEnvironment() || debug)
|
51
|
+
console.error("Registered script is not a Needle Engine component. \nThe script will be ignored. Please make sure your component extends \"Behaviour\" imported from \"@needle-tools/engine\"\n", script);
|
52
|
+
new_scripts_buffer.splice(i, 1);
|
53
|
+
i--;
|
54
|
+
continue;
|
55
|
+
}
|
49
56
|
if (script.destroyed) continue;
|
50
57
|
if (!script.gameObject) {
|
51
58
|
console.error("MISSING GAMEOBJECT - will ignore", script);
|
@@ -11,6 +11,7 @@
|
|
11
11
|
import { NEEDLE_components } from "./extensions/NEEDLE_components.js";
|
12
12
|
import { registerPrewarmObject } from "./engine_mainloop_utils.js";
|
13
13
|
import { Object3D } from "three";
|
14
|
+
import { showBalloonMessage } from "./debug/index.js";
|
14
15
|
|
15
16
|
|
16
17
|
export class NeedleGltfLoader implements INeedleGltfLoader {
|
@@ -131,6 +132,7 @@
|
|
131
132
|
// but due to the async nature and potentially triggering multiple loads at the same time
|
132
133
|
// we need to make sure the extensions dont override each other
|
133
134
|
// creating new loaders should not be expensive as well
|
135
|
+
checkIfUserAttemptedToLoadALocalFile(url)
|
134
136
|
const loader = await createGLTFLoader(url, context);
|
135
137
|
const componentsExtension = registerComponentExtension(loader);
|
136
138
|
return new Promise((resolve, reject) => {
|
@@ -158,6 +160,14 @@
|
|
158
160
|
});
|
159
161
|
}
|
160
162
|
|
163
|
+
function checkIfUserAttemptedToLoadALocalFile(url: string) {
|
164
|
+
const fullurl = new URL(url, window.location.href).href;
|
165
|
+
if (fullurl.startsWith("file://")) {
|
166
|
+
const msg = "Hi - it looks like you are trying to load a local file which will not work. You need to use a webserver to serve your files.\nPlease refer to the documentation on <a href=\"https://fwd.needle.tools/needle-engine/docs/local-server\">https://docs.needle.tools</a> or ask for help in our <a href=\"https://discord.needle.tools\">discord community</a>";
|
167
|
+
showBalloonMessage(msg);
|
168
|
+
console.warn(msg)
|
169
|
+
}
|
170
|
+
}
|
161
171
|
|
162
172
|
// TODO: save references in guid map
|
163
173
|
// const guidMap = {};
|