@needle-tools/engine 3.5.5-alpha.1 → 3.5.7-alpha
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 +17 -0
- package/dist/needle-engine.js +14494 -14367
- package/dist/needle-engine.light.js +82420 -0
- package/dist/needle-engine.light.min.js +5057 -0
- package/dist/needle-engine.light.umd.cjs +5057 -0
- package/dist/needle-engine.min.js +331 -329
- package/dist/needle-engine.umd.cjs +327 -325
- package/lib/engine/engine_addressables.js +2 -2
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_components.d.ts +2 -2
- package/lib/engine/engine_components.js +7 -2
- package/lib/engine/engine_components.js.map +1 -1
- package/lib/engine/engine_networking.d.ts +6 -3
- package/lib/engine/engine_networking.js +57 -30
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine-components/Component.d.ts +3 -0
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/SyncedRoom.d.ts +3 -0
- package/lib/engine-components/SyncedRoom.js +10 -6
- package/lib/engine-components/SyncedRoom.js.map +1 -1
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +5 -3
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js.map +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.js +2 -1
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/USDZText.d.ts +10 -3
- package/lib/engine-components/export/usdz/extensions/USDZText.js +88 -8
- package/lib/engine-components/export/usdz/extensions/USDZText.js.map +1 -1
- package/lib/engine-components/js-extensions/Object3D.js +4 -1
- package/lib/engine-components/js-extensions/Object3D.js.map +1 -1
- package/lib/engine-components/ui/Button.js +10 -0
- package/lib/engine-components/ui/Button.js.map +1 -1
- package/lib/engine-components/ui/Canvas.js +3 -2
- package/lib/engine-components/ui/Canvas.js.map +1 -1
- package/lib/engine-components/ui/CanvasGroup.js +5 -5
- package/lib/engine-components/ui/CanvasGroup.js.map +1 -1
- package/lib/engine-components/ui/Graphic.d.ts +3 -0
- package/lib/engine-components/ui/Graphic.js +19 -5
- package/lib/engine-components/ui/Graphic.js.map +1 -1
- package/lib/engine-components/ui/Interfaces.d.ts +4 -1
- package/lib/engine-components/ui/Interfaces.js.map +1 -1
- package/lib/engine-components/ui/RectTransform.d.ts +3 -1
- package/lib/engine-components/ui/RectTransform.js +22 -22
- package/lib/engine-components/ui/RectTransform.js.map +1 -1
- package/lib/engine-components/ui/Text.d.ts +3 -1
- package/lib/engine-components/ui/Text.js +6 -0
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/engine-components/webxr/WebXR.js +1 -2
- package/lib/engine-components/webxr/WebXR.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/src/engine/engine_addressables.ts +1 -1
- package/src/engine/engine_components.ts +7 -2
- package/src/engine/engine_networking.ts +65 -34
- package/src/engine-components/Component.ts +3 -1
- package/src/engine-components/ParticleSystemModules.ts +1483 -1483
- package/src/engine-components/SyncedRoom.ts +11 -9
- package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +9 -6
- package/src/engine-components/export/usdz/USDZExporter.ts +2 -1
- package/src/engine-components/export/usdz/extensions/USDZText.ts +99 -11
- package/src/engine-components/js-extensions/Object3D.ts +5 -1
- package/src/engine-components/ui/Button.ts +5 -0
- package/src/engine-components/ui/Canvas.ts +3 -2
- package/src/engine-components/ui/CanvasGroup.ts +7 -6
- package/src/engine-components/ui/Graphic.ts +27 -15
- package/src/engine-components/ui/Interfaces.ts +5 -1
- package/src/engine-components/ui/RectTransform.ts +32 -28
- package/src/engine-components/ui/Text.ts +9 -4
- package/src/engine-components/webxr/WebXR.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/engine",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.7-alpha",
|
|
4
4
|
"description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in",
|
|
5
5
|
"main": "dist/needle-engine.umd.cjs",
|
|
6
6
|
"type": "module",
|
|
@@ -20,8 +20,9 @@
|
|
|
20
20
|
"scripts": {
|
|
21
21
|
"dev": "npm-watch",
|
|
22
22
|
"font:generate": "node plugins/generate-font.js",
|
|
23
|
-
"build": "npm run build:dist && npm run build:src",
|
|
23
|
+
"build": "npm run build:dist && npm run build:dist:light && npm run build:src",
|
|
24
24
|
"build:dist": "vite build",
|
|
25
|
+
"build:dist:light": "vite build -- --light --noclear",
|
|
25
26
|
"build:src": "tsc --outDir ./lib --noEmit false --declaration",
|
|
26
27
|
"build:license": "node plugins/publish/create-license.mjs",
|
|
27
28
|
"test:circular-imports": "node plugins/check-circular-imports.js",
|
|
@@ -212,7 +212,6 @@ export class AssetReference {
|
|
|
212
212
|
|
|
213
213
|
private async onInstantiate(parent?: Object3D | InstantiateOptions, networked: boolean = false, saveOnServer?: boolean) {
|
|
214
214
|
const context = Context.Current;
|
|
215
|
-
if (!parent) parent = context.scene;
|
|
216
215
|
if (this.mustLoad) {
|
|
217
216
|
await this.loadAssetAsync();
|
|
218
217
|
}
|
|
@@ -235,6 +234,7 @@ export class AssetReference {
|
|
|
235
234
|
Object.assign(options, parent);
|
|
236
235
|
}
|
|
237
236
|
}
|
|
237
|
+
if (!options.parent) options.parent = context.scene;
|
|
238
238
|
|
|
239
239
|
let count = AssetReference.currentlyInstantiating.get(this.uri);
|
|
240
240
|
// allow up to 10000 instantiations of the same prefab in the same frame
|
|
@@ -75,20 +75,25 @@ export function addNewComponent<T extends IComponent>(obj: Object3D, componentIn
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
export function moveComponentInstance(obj: Object3D, componentInstance: IComponent) {
|
|
78
|
-
if (componentInstance.gameObject === obj) return;
|
|
78
|
+
if (componentInstance.gameObject === obj) return componentInstance;
|
|
79
79
|
// TODO: update raycast array
|
|
80
80
|
if (componentInstance.gameObject && componentInstance.gameObject.userData.components) {
|
|
81
81
|
const index = componentInstance.gameObject.userData.components.indexOf(componentInstance);
|
|
82
82
|
componentInstance.gameObject.userData.components.splice(index, 1);
|
|
83
83
|
}
|
|
84
84
|
if (!obj.userData.components) obj.userData.components = [];
|
|
85
|
-
else if (obj.userData.components.includes(componentInstance)) return;
|
|
85
|
+
else if (obj.userData.components.includes(componentInstance)) return componentInstance;
|
|
86
86
|
// TODO: do we want to disable and enable when moving?
|
|
87
87
|
// componentInstance.__internalDisable();
|
|
88
88
|
obj.userData.components.push(componentInstance);
|
|
89
89
|
componentInstance.gameObject = obj as IGameObject;
|
|
90
90
|
// componentInstance.__internalEnable();
|
|
91
91
|
// componentInstance.transform = obj;
|
|
92
|
+
if (componentInstance.guid === undefined || componentInstance.guid === "invalid") {
|
|
93
|
+
componentInstance.guid = idProvider.generateUUID();
|
|
94
|
+
}
|
|
95
|
+
registerComponent(componentInstance);
|
|
96
|
+
return componentInstance;
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// const serverUrl = 'wss://tiny-server-1-r26roub2hq-ew.a.run.app/';
|
|
4
|
-
let serverUrl = 'wss://needle-tiny-starter.glitch.me/socket';
|
|
1
|
+
const defaultNetworkingBackendUrlProvider = "https://urls.needle.tools/default-networking-backend/index";
|
|
2
|
+
let serverUrl : string | undefined = "wss://needle-tiny-starter.glitch.me/socket";
|
|
5
3
|
|
|
6
4
|
import { Websocket, WebsocketBuilder } from 'websocket-ts';
|
|
7
5
|
// import { Networking } from '../engine-components/Networking';
|
|
@@ -85,6 +83,8 @@ declare type OwnershipResponse = {
|
|
|
85
83
|
value: boolean;
|
|
86
84
|
}
|
|
87
85
|
|
|
86
|
+
declare type WebsocketSendType = IModel | object | boolean | null | string | number;
|
|
87
|
+
|
|
88
88
|
export class OwnershipModel {
|
|
89
89
|
|
|
90
90
|
public guid: string;
|
|
@@ -308,8 +308,9 @@ export class NetworkConnection implements INetworkConnection {
|
|
|
308
308
|
this.send(RoomEvents.Leave, { room: room });
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
-
public send(key: string | OwnershipEvent, data:
|
|
311
|
+
public send<T extends WebsocketSendType>(key: string | OwnershipEvent, data: T | null = null, queue: SendQueue = SendQueue.Queued) {
|
|
312
312
|
|
|
313
|
+
//@ts-ignore
|
|
313
314
|
if (data === null) data = {};
|
|
314
315
|
|
|
315
316
|
if (queue === SendQueue.Queued) {
|
|
@@ -331,7 +332,7 @@ export class NetworkConnection implements INetworkConnection {
|
|
|
331
332
|
delete this._state[guid];
|
|
332
333
|
}
|
|
333
334
|
|
|
334
|
-
public sendDeleteRemoteStateAll(){
|
|
335
|
+
public sendDeleteRemoteStateAll() {
|
|
335
336
|
this.send("delete-all-state");
|
|
336
337
|
this._state = {};
|
|
337
338
|
}
|
|
@@ -404,23 +405,25 @@ export class NetworkConnection implements INetworkConnection {
|
|
|
404
405
|
this.netWebSocketUrlProvider = prov;
|
|
405
406
|
}
|
|
406
407
|
|
|
407
|
-
public connect() {
|
|
408
|
-
if (this.connected) return;
|
|
408
|
+
public async connect() {
|
|
409
|
+
if (this.connected) return Promise.resolve(true);
|
|
409
410
|
if (debugNet)
|
|
410
411
|
console.log("connecting");
|
|
411
|
-
// this.channel = geckos({ port: 9208, url: 'http://127.0.0.1' });
|
|
412
|
-
// this.channel.onConnect(this.onConnectGeckosIo.bind(this));
|
|
413
|
-
// const networking = GameObject.findObjectOfType(Networking, this.context, false);
|
|
414
412
|
const overrideUrl = this.netWebSocketUrlProvider?.getWebsocketUrl();
|
|
415
413
|
if (overrideUrl) {
|
|
416
414
|
serverUrl = overrideUrl;
|
|
417
415
|
}
|
|
418
|
-
else if(isHostedOnGlitch()) {
|
|
416
|
+
else if (isHostedOnGlitch()) {
|
|
419
417
|
serverUrl = "wss://" + window.location.host + "/socket";
|
|
420
418
|
}
|
|
421
|
-
this.connectWebsocket();
|
|
419
|
+
return this.connectWebsocket();
|
|
422
420
|
};
|
|
423
421
|
|
|
422
|
+
public disconnect() {
|
|
423
|
+
this._ws?.close();
|
|
424
|
+
this._ws = undefined;
|
|
425
|
+
}
|
|
426
|
+
|
|
424
427
|
private _listeners: { [key: string]: Function[] } = {};
|
|
425
428
|
private _listenersBinary: { [key: string]: BinaryCallback[] } = {};
|
|
426
429
|
private connected: boolean = false;
|
|
@@ -428,7 +431,6 @@ export class NetworkConnection implements INetworkConnection {
|
|
|
428
431
|
private _connectionId: string | null = null;
|
|
429
432
|
|
|
430
433
|
// Websocket ------------------------------------------------------------
|
|
431
|
-
private _isConnectingToWebsocket: boolean = false;
|
|
432
434
|
private _ws: Websocket | undefined;
|
|
433
435
|
private _waitingForSocket: { [key: string]: Array<Function> } = {};
|
|
434
436
|
private _isInRoom: boolean = false;
|
|
@@ -439,26 +441,55 @@ export class NetworkConnection implements INetworkConnection {
|
|
|
439
441
|
private _state: { [key: string]: any } = {};
|
|
440
442
|
private _currentDelay: number = -1;
|
|
441
443
|
|
|
444
|
+
private _connectingToWebsocketPromise: Promise<boolean> | null = null;
|
|
445
|
+
|
|
442
446
|
private connectWebsocket() {
|
|
443
|
-
if (this.
|
|
444
|
-
this.
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
447
|
+
if (this._connectingToWebsocketPromise) return this._connectingToWebsocketPromise;
|
|
448
|
+
return this._connectingToWebsocketPromise = new Promise(async (res, _) => {
|
|
449
|
+
let didResolve = false;
|
|
450
|
+
const resolve = (val: boolean) => {
|
|
451
|
+
if (didResolve) return;
|
|
452
|
+
didResolve = true;
|
|
453
|
+
res(val);
|
|
454
|
+
}
|
|
455
|
+
if(serverUrl === undefined){
|
|
456
|
+
console.log("Fetch default backend url: " + defaultNetworkingBackendUrlProvider);
|
|
457
|
+
let failed = false;
|
|
458
|
+
const defaultUrlResponse = await fetch(defaultNetworkingBackendUrlProvider);
|
|
459
|
+
serverUrl = await defaultUrlResponse.text();
|
|
460
|
+
if(failed) return;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
if(serverUrl === undefined){
|
|
464
|
+
resolve(false);
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
console.log("⊡ Connecting to networking backend on\n" + serverUrl)
|
|
469
|
+
const ws = new WebsocketBuilder(serverUrl)
|
|
470
|
+
.onOpen(() => {
|
|
471
|
+
this._connectingToWebsocketPromise = null;
|
|
472
|
+
this._ws = ws;
|
|
473
|
+
this.connected = true;
|
|
474
|
+
console.log("⊞ Connected to networking backend\n" + serverUrl);
|
|
475
|
+
resolve(true);
|
|
476
|
+
this.onSendQueued(SendQueue.OnConnection);
|
|
477
|
+
})
|
|
478
|
+
.onClose((_evt) => {
|
|
479
|
+
this._connectingToWebsocketPromise = null;
|
|
480
|
+
this.connected = false;
|
|
481
|
+
this._isInRoom = false;
|
|
482
|
+
resolve(false);
|
|
483
|
+
})
|
|
484
|
+
.onError((i, ev) => {
|
|
485
|
+
console.error("⊠ Websocket error", i, ev);
|
|
486
|
+
resolve(false);
|
|
487
|
+
})
|
|
488
|
+
.onMessage(this.onMessage.bind(this))
|
|
489
|
+
.onRetry(() => { console.log("Retry connecting to networking websocket") })
|
|
490
|
+
.build();
|
|
491
|
+
|
|
492
|
+
});
|
|
462
493
|
}
|
|
463
494
|
|
|
464
495
|
private onMessage(_, ev) {
|
|
@@ -575,7 +606,7 @@ export class NetworkConnection implements INetworkConnection {
|
|
|
575
606
|
break;
|
|
576
607
|
|
|
577
608
|
case "all-room-state-deleted":
|
|
578
|
-
if(debugNet) console.log("RECEIVED all-room-state-deleted");
|
|
609
|
+
if (debugNet) console.log("RECEIVED all-room-state-deleted");
|
|
579
610
|
this._state = {};
|
|
580
611
|
break;
|
|
581
612
|
|
|
@@ -273,8 +273,10 @@ export abstract class GameObject extends Object3D implements Object3D, IGameObje
|
|
|
273
273
|
|
|
274
274
|
// these are implemented via threejs object extensions
|
|
275
275
|
abstract activeSelf: boolean;
|
|
276
|
+
/** creates a new component on this gameObject */
|
|
276
277
|
abstract addNewComponent<T>(type: Constructor<T>): T | null;
|
|
277
|
-
|
|
278
|
+
/** adds an existing component to this gameObject */
|
|
279
|
+
abstract addComponent(comp: IComponent): void;
|
|
278
280
|
abstract removeComponent(comp: Component): Component;
|
|
279
281
|
abstract getOrAddComponent<T>(typeName: Constructor<T> | null): T;
|
|
280
282
|
abstract getComponent<T>(type: Constructor<T>): T | null;
|