@needle-tools/engine 2.34.0-pre → 2.35.1-pre
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 +16 -0
- package/dist/needle-engine.d.ts +3128 -2942
- package/dist/needle-engine.js +455 -455
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +54 -54
- package/dist/needle-engine.min.js.map +4 -4
- package/lib/engine/api.d.ts +3 -0
- package/lib/engine/api.js +4 -0
- package/lib/engine/api.js.map +1 -0
- package/lib/engine/engine.d.ts +4 -3
- package/lib/engine/engine_addressables.d.ts +5 -4
- package/lib/engine/engine_addressables.js +8 -7
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_components.d.ts +17 -0
- package/lib/engine/engine_components.js +240 -0
- package/lib/engine/engine_components.js.map +1 -0
- package/lib/engine/engine_element.js +4 -3
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_element_loading.js +4 -1
- package/lib/engine/engine_element_loading.js.map +1 -1
- package/lib/engine/engine_gameobject.d.ts +33 -0
- package/lib/engine/engine_gameobject.js +449 -0
- package/lib/engine/engine_gameobject.js.map +1 -0
- package/lib/engine/engine_gltf.d.ts +13 -2
- package/lib/engine/engine_gltf.js +7 -1
- package/lib/engine/engine_gltf.js.map +1 -1
- package/lib/engine/engine_gltf_builtin_components.d.ts +3 -3
- package/lib/engine/engine_gltf_builtin_components.js +2 -3
- package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
- package/lib/engine/engine_lightdata.d.ts +1 -1
- package/lib/engine/engine_lightdata.js.map +1 -1
- package/lib/engine/engine_mainloop_utils.d.ts +2 -2
- package/lib/engine/engine_mainloop_utils.js +7 -6
- package/lib/engine/engine_mainloop_utils.js.map +1 -1
- package/lib/engine/engine_networking.d.ts +6 -10
- package/lib/engine/engine_networking.js +7 -11
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine/engine_networking_files.d.ts +1 -1
- package/lib/engine/engine_networking_files.js +8 -7
- package/lib/engine/engine_networking_files.js.map +1 -1
- package/lib/engine/engine_networking_files_default_components.d.ts +2 -2
- package/lib/engine/engine_networking_files_default_components.js +38 -43
- package/lib/engine/engine_networking_files_default_components.js.map +1 -1
- package/lib/engine/engine_networking_instantiate.d.ts +8 -6
- package/lib/engine/engine_networking_instantiate.js +12 -9
- package/lib/engine/engine_networking_instantiate.js.map +1 -1
- package/lib/engine/engine_networking_types.d.ts +14 -0
- package/lib/engine/engine_networking_types.js +8 -0
- package/lib/engine/engine_networking_types.js.map +1 -0
- package/lib/engine/engine_physics.d.ts +5 -24
- package/lib/engine/engine_physics.js +27 -61
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_rendererdata.d.ts +1 -1
- package/lib/engine/engine_rendererdata.js.map +1 -1
- package/lib/engine/engine_scenetools.d.ts +2 -2
- package/lib/engine/engine_scenetools.js +22 -5
- package/lib/engine/engine_scenetools.js.map +1 -1
- package/lib/engine/engine_serialization_builtin_serializer.d.ts +1 -1
- package/lib/engine/engine_serialization_core.d.ts +1 -1
- package/lib/engine/engine_serialization_decorator.d.ts +1 -1
- package/lib/engine/engine_setup.d.ts +14 -15
- package/lib/engine/engine_setup.js +34 -23
- package/lib/engine/engine_setup.js.map +1 -1
- package/lib/engine/engine_three_utils.js +0 -6
- package/lib/engine/engine_three_utils.js.map +1 -1
- package/lib/engine/engine_types.d.ts +108 -0
- package/lib/engine/engine_types.js +50 -0
- package/lib/engine/engine_types.js.map +1 -0
- package/lib/engine/engine_utils.d.ts +1 -1
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_components.js +2 -2
- package/lib/engine/extensions/NEEDLE_components.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_deferred_texture.d.ts +1 -1
- package/lib/engine/extensions/NEEDLE_lighting_settings.d.ts +1 -1
- package/lib/engine/extensions/NEEDLE_lightmaps.d.ts +1 -1
- package/lib/engine/extensions/NEEDLE_render_objects.d.ts +2 -2
- package/lib/engine/extensions/NEEDLE_techniques_webgl.d.ts +1 -1
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js +3 -2
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js.map +1 -1
- package/lib/engine/extensions/extensions.d.ts +1 -1
- package/lib/engine-components/Animator.js.map +1 -1
- package/lib/engine-components/AvatarLoader.js +6 -5
- package/lib/engine-components/AvatarLoader.js.map +1 -1
- package/lib/engine-components/Camera.d.ts +2 -2
- package/lib/engine-components/Camera.js +6 -12
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/CameraUtils.d.ts +3 -0
- package/lib/engine-components/CameraUtils.js +15 -0
- package/lib/engine-components/CameraUtils.js.map +1 -0
- package/lib/engine-components/Collider.d.ts +3 -1
- package/lib/engine-components/Collider.js +11 -0
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Component.d.ts +21 -55
- package/lib/engine-components/Component.js +67 -466
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/Duplicatable.js +2 -1
- package/lib/engine-components/Duplicatable.js.map +1 -1
- package/lib/engine-components/LODGroup.js.map +1 -1
- package/lib/engine-components/Light.d.ts +2 -1
- package/lib/engine-components/Light.js +2 -2
- package/lib/engine-components/Light.js.map +1 -1
- package/lib/engine-components/NestedGltf.js +2 -1
- package/lib/engine-components/NestedGltf.js.map +1 -1
- package/lib/engine-components/Networking.d.ts +3 -1
- package/lib/engine-components/Networking.js +3 -0
- package/lib/engine-components/Networking.js.map +1 -1
- package/lib/engine-components/OrbitControls.js +4 -2
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/Renderer.d.ts +3 -2
- package/lib/engine-components/Renderer.js +2 -0
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/{Rigidbody.d.ts → RigidBody.d.ts} +2 -1
- package/lib/engine-components/{Rigidbody.js → RigidBody.js} +1 -1
- package/lib/engine-components/{Rigidbody.js.map → RigidBody.js.map} +1 -1
- package/lib/engine-components/ScreenCapture.js.map +1 -1
- package/lib/engine-components/SpectatorCamera.js.map +1 -1
- package/lib/engine-components/SyncedCamera.js +2 -1
- package/lib/engine-components/SyncedCamera.js.map +1 -1
- package/lib/engine-components/SyncedTransform.js.map +1 -1
- package/lib/engine-components/TestRunner.js.map +1 -1
- package/lib/engine-components/Voip.js +2 -1
- package/lib/engine-components/Voip.js.map +1 -1
- package/lib/engine-components/WebXR.js.map +1 -1
- package/lib/engine-components/WebXRController.js +28 -8
- package/lib/engine-components/WebXRController.js.map +1 -1
- package/lib/engine-components/WebXRGrabRendering.d.ts +1 -1
- package/lib/engine-components/WebXRGrabRendering.js +1 -1
- package/lib/engine-components/WebXRGrabRendering.js.map +1 -1
- package/lib/engine-components/WebXRSync.js +1 -1
- package/lib/engine-components/WebXRSync.js.map +1 -1
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +1 -1
- package/lib/engine-components/codegen/components.js +1 -1
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/js-extensions/ExtensionUtils.d.ts +4 -0
- package/lib/engine-components/js-extensions/ExtensionUtils.js +56 -0
- package/lib/engine-components/js-extensions/ExtensionUtils.js.map +1 -0
- package/lib/engine-components/js-extensions/Object3D.js +27 -50
- package/lib/engine-components/js-extensions/Object3D.js.map +1 -1
- package/lib/engine-components/js-extensions/Vector.d.ts +2 -0
- package/lib/engine-components/js-extensions/Vector.js +16 -0
- package/lib/engine-components/js-extensions/Vector.js.map +1 -0
- package/lib/engine-components/timeline/PlayableDirector.d.ts +2 -1
- package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
- package/lib/engine-components/ui/BaseUIComponent.d.ts +1 -0
- package/lib/engine-components/ui/BaseUIComponent.js +11 -5
- package/lib/engine-components/ui/BaseUIComponent.js.map +1 -1
- package/lib/engine-components/ui/Canvas.d.ts +3 -0
- package/lib/engine-components/ui/Canvas.js +12 -1
- package/lib/engine-components/ui/Canvas.js.map +1 -1
- package/lib/engine-components/ui/CanvasScaler.d.ts +0 -0
- package/lib/engine-components/ui/CanvasScaler.js +17 -0
- package/lib/engine-components/ui/CanvasScaler.js.map +1 -0
- package/lib/engine-components/ui/EventSystem.d.ts +1 -1
- package/lib/engine-components/ui/EventSystem.js +11 -31
- package/lib/engine-components/ui/EventSystem.js.map +1 -1
- package/lib/engine-components/ui/Graphic.js +2 -1
- package/lib/engine-components/ui/Graphic.js.map +1 -1
- package/lib/engine-components/ui/Keyboard.js +2 -1
- package/lib/engine-components/ui/Keyboard.js.map +1 -1
- package/lib/engine-components/ui/RaycastUtils.d.ts +11 -0
- package/lib/engine-components/ui/RaycastUtils.js +62 -0
- package/lib/engine-components/ui/RaycastUtils.js.map +1 -0
- package/lib/engine-components/ui/Raycaster.js.map +1 -1
- package/lib/engine-components/ui/Text.js +8 -3
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/engine-components/ui/Utils.js +3 -2
- package/lib/engine-components/ui/Utils.js.map +1 -1
- package/lib/needle-engine.d.ts +3 -1
- package/lib/needle-engine.js +4 -2
- package/lib/needle-engine.js.map +1 -1
- package/package.json +12 -1
- package/src/engine/api.ts +3 -0
- package/src/engine/codegen/register_types.js +2 -2
- package/src/engine/engine_addressables.ts +12 -10
- package/src/engine/{engine_components.js → engine_components.ts} +66 -61
- package/src/engine/engine_element.ts +4 -3
- package/src/engine/engine_element_loading.ts +5 -1
- package/src/engine/engine_gameobject.ts +506 -0
- package/src/engine/engine_gltf.ts +21 -2
- package/src/engine/engine_gltf_builtin_components.ts +8 -7
- package/src/engine/engine_lightdata.ts +1 -1
- package/src/engine/engine_mainloop_utils.ts +13 -11
- package/src/engine/engine_networking.ts +14 -17
- package/src/engine/engine_networking_files.ts +14 -11
- package/src/engine/engine_networking_files_default_components.ts +53 -52
- package/src/engine/engine_networking_instantiate.ts +24 -14
- package/src/engine/engine_networking_types.ts +19 -0
- package/src/engine/engine_physics.ts +45 -77
- package/src/engine/engine_rendererdata.ts +1 -1
- package/src/engine/engine_scenetools.ts +30 -6
- package/src/engine/engine_serialization_core.ts +1 -1
- package/src/engine/engine_serialization_decorator.ts +1 -1
- package/src/engine/engine_setup.ts +51 -37
- package/src/engine/engine_three_utils.ts +0 -8
- package/src/engine/engine_types.ts +188 -0
- package/src/engine/engine_utils.ts +1 -3
- package/src/engine/extensions/NEEDLE_components.ts +2 -2
- package/src/engine/extensions/NEEDLE_deferred_texture.ts +1 -1
- package/src/engine/extensions/NEEDLE_lighting_settings.ts +1 -1
- package/src/engine/extensions/NEEDLE_lightmaps.ts +1 -1
- package/src/engine/extensions/NEEDLE_render_objects.ts +4 -4
- package/src/engine/extensions/NEEDLE_techniques_webgl.ts +5 -4
- package/src/engine/extensions/extensions.ts +1 -1
- package/src/engine-components/Animator.ts +3 -3
- package/src/engine-components/AvatarLoader.ts +6 -5
- package/src/engine-components/Camera.ts +10 -13
- package/src/engine-components/CameraUtils.ts +15 -0
- package/src/engine-components/Collider.ts +17 -2
- package/src/engine-components/Component.ts +87 -541
- package/src/engine-components/Duplicatable.ts +4 -3
- package/src/engine-components/LODGroup.ts +1 -1
- package/src/engine-components/Light.ts +3 -2
- package/src/engine-components/NestedGltf.ts +2 -1
- package/src/engine-components/Networking.ts +6 -1
- package/src/engine-components/OrbitControls.ts +5 -5
- package/src/engine-components/Renderer.ts +5 -1
- package/src/engine-components/RigidBody.ts +2 -1
- package/src/engine-components/ScreenCapture.ts +1 -1
- package/src/engine-components/SpectatorCamera.ts +7 -5
- package/src/engine-components/SyncedCamera.ts +2 -1
- package/src/engine-components/SyncedTransform.ts +1 -1
- package/src/engine-components/TestRunner.ts +1 -2
- package/src/engine-components/Voip.ts +2 -1
- package/src/engine-components/WebXR.ts +2 -2
- package/src/engine-components/WebXRController.ts +30 -10
- package/src/engine-components/WebXRGrabRendering.ts +1 -1
- package/src/engine-components/WebXRSync.ts +1 -1
- package/src/engine-components/avatar/Avatar_Brain_LookAt.ts +2 -1
- package/src/engine-components/codegen/components.ts +1 -1
- package/src/engine-components/js-extensions/ExtensionUtils.ts +66 -0
- package/src/engine-components/js-extensions/Object3D.ts +37 -61
- package/src/engine-components/js-extensions/Vector.ts +17 -0
- package/src/engine-components/timeline/PlayableDirector.ts +2 -1
- package/src/engine-components/ui/BaseUIComponent.ts +17 -6
- package/src/engine-components/ui/Canvas.ts +14 -2
- package/src/engine-components/ui/CanvasScaler.ts +21 -0
- package/src/engine-components/ui/EventSystem.ts +11 -25
- package/src/engine-components/ui/Graphic.ts +2 -1
- package/src/engine-components/ui/Keyboard.ts +2 -1
- package/src/engine-components/ui/RaycastUtils.ts +64 -0
- package/src/engine-components/ui/Raycaster.ts +2 -0
- package/src/engine-components/ui/Text.ts +8 -4
- package/src/engine-components/ui/Utils.ts +3 -2
- package/src/needle-engine.ts +7 -2
|
@@ -4,21 +4,19 @@
|
|
|
4
4
|
let serverUrl = 'wss://needle-tiny-starter.glitch.me/socket';
|
|
5
5
|
|
|
6
6
|
import { Websocket, WebsocketBuilder } from 'websocket-ts';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { Context, ContextArgs } from './engine_setup';
|
|
7
|
+
// import { Networking } from '../engine-components/Networking';
|
|
8
|
+
import { Context } from './engine_setup';
|
|
10
9
|
import * as utils from "./engine_utils";
|
|
11
10
|
import * as flatbuffers from 'flatbuffers';
|
|
12
11
|
import * as schemes from "../engine-schemes/schemes";
|
|
13
12
|
import { PeerNetworking } from './engine_networking_peer';
|
|
13
|
+
import { IModel, INetworkConnection, SendQueue } from './engine_networking_types';
|
|
14
14
|
|
|
15
15
|
export const debugNet = utils.getParam("debugnet") ? true : false;
|
|
16
16
|
export const debugOwner = debugNet || utils.getParam("debugowner") ? true : false;
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
guid: string;
|
|
21
|
-
dontSave?: boolean; // if set to true the model will not be saved in the server room state
|
|
18
|
+
export interface INetworkingWebsocketUrlProvider {
|
|
19
|
+
getWebsocketUrl() : string | null;
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
export declare interface IConnectionData {
|
|
@@ -225,18 +223,11 @@ export class OwnershipModel {
|
|
|
225
223
|
}
|
|
226
224
|
|
|
227
225
|
|
|
228
|
-
export enum SendQueue {
|
|
229
|
-
OnConnection,
|
|
230
|
-
OnRoomJoin,
|
|
231
|
-
Queued,
|
|
232
|
-
Immediate,
|
|
233
|
-
}
|
|
234
|
-
|
|
235
226
|
export declare type BinaryCallback = {
|
|
236
227
|
(data: any | flatbuffers.ByteBuffer): void;
|
|
237
228
|
}
|
|
238
229
|
|
|
239
|
-
export class NetworkConnection {
|
|
230
|
+
export class NetworkConnection implements INetworkConnection {
|
|
240
231
|
|
|
241
232
|
private context: Context;
|
|
242
233
|
private _peer: PeerNetworking | null = null;
|
|
@@ -395,14 +386,20 @@ export class NetworkConnection {
|
|
|
395
386
|
}
|
|
396
387
|
}
|
|
397
388
|
|
|
389
|
+
private netWebSocketUrlProvider? : INetworkingWebsocketUrlProvider;
|
|
390
|
+
|
|
391
|
+
public registerProvider(prov : INetworkingWebsocketUrlProvider){
|
|
392
|
+
this.netWebSocketUrlProvider = prov;
|
|
393
|
+
}
|
|
394
|
+
|
|
398
395
|
public connect() {
|
|
399
396
|
if (this.connected) return;
|
|
400
397
|
if (debugNet)
|
|
401
398
|
console.log("connecting");
|
|
402
399
|
// this.channel = geckos({ port: 9208, url: 'http://127.0.0.1' });
|
|
403
400
|
// this.channel.onConnect(this.onConnectGeckosIo.bind(this));
|
|
404
|
-
const networking = GameObject.findObjectOfType(Networking, this.context, false);
|
|
405
|
-
const overrideUrl =
|
|
401
|
+
// const networking = GameObject.findObjectOfType(Networking, this.context, false);
|
|
402
|
+
const overrideUrl = this.netWebSocketUrlProvider?.getWebsocketUrl();
|
|
406
403
|
if (overrideUrl) {
|
|
407
404
|
serverUrl = overrideUrl;
|
|
408
405
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { GameObject } from "../engine-components/Component";
|
|
2
1
|
import { Context } from "../engine/engine_setup";
|
|
3
|
-
import { loadSync, parseSync } from "../engine/engine_scenetools";
|
|
2
|
+
// import { loadSync, parseSync } from "../engine/engine_scenetools";
|
|
4
3
|
import * as THREE from "three";
|
|
5
4
|
import * as web from "../engine/engine_web_api";
|
|
6
|
-
import {
|
|
5
|
+
import { NetworkConnection } from "../engine/engine_networking";
|
|
7
6
|
import { generateSeed, InstantiateIdProvider } from "../engine/engine_networking_instantiate";
|
|
8
7
|
import * as def from "./engine_networking_files_default_components"
|
|
9
8
|
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js'
|
|
9
|
+
import { getLoader } from "../engine/engine_gltf";
|
|
10
|
+
import { IModel } from "./engine_networking_types";
|
|
11
|
+
import { IGameObject } from "./engine_types";
|
|
12
|
+
import { findByGuid } from "./engine_gameobject";
|
|
10
13
|
|
|
11
14
|
export enum File_Event {
|
|
12
15
|
File_Spawned = "file-spawned",
|
|
@@ -50,9 +53,9 @@ export async function addFile(file: File, context: Context, backendUrl?: string)
|
|
|
50
53
|
// first load it locally
|
|
51
54
|
const seed = generateSeed();
|
|
52
55
|
const prov = new InstantiateIdProvider(seed);
|
|
53
|
-
const gltf: GLTF = await loadSync(context, content, prov, true) as GLTF;
|
|
56
|
+
const gltf: GLTF = await getLoader().loadSync(context, content, prov, true) as GLTF;
|
|
54
57
|
if (gltf && gltf.scene) {
|
|
55
|
-
const obj = gltf.scene as unknown as
|
|
58
|
+
const obj = gltf.scene as unknown as IGameObject;
|
|
56
59
|
// if we dont have a guid yet (because components guids are actually created in a callback a bit later)
|
|
57
60
|
// we just use the same seed and generate a guid for the root only
|
|
58
61
|
// this should be the exact same guid the instantiate call will produce
|
|
@@ -81,9 +84,9 @@ export async function addFileFromUrl(url: URL, context: Context): Promise<GLTF |
|
|
|
81
84
|
return new Promise(async (resolve, _reject) => {
|
|
82
85
|
const seed = generateSeed();
|
|
83
86
|
const prov = new InstantiateIdProvider(seed);
|
|
84
|
-
const gltf: GLTF = await loadSync(context, url.toString(), prov, true) as GLTF;
|
|
87
|
+
const gltf: GLTF = await getLoader().loadSync(context, url.toString(), prov, true) as GLTF;
|
|
85
88
|
if (gltf && gltf.scene) {
|
|
86
|
-
const obj = gltf.scene as unknown as
|
|
89
|
+
const obj = gltf.scene as unknown as IGameObject;
|
|
87
90
|
// handleUpload(context.connection, file, seed, obj); // TODO needs to upload the URL only and store that
|
|
88
91
|
def.onDynamicObjectAdded(obj, prov, gltf);
|
|
89
92
|
resolve(gltf);
|
|
@@ -108,7 +111,7 @@ export function beginListenFileSpawn(context: Context) {
|
|
|
108
111
|
}
|
|
109
112
|
if (bin) {
|
|
110
113
|
const prov = new InstantiateIdProvider(evt.seed);
|
|
111
|
-
const gltf = await parseSync(context, bin, null!, prov);
|
|
114
|
+
const gltf = await getLoader().parseSync(context, bin, null!, prov);
|
|
112
115
|
if (gltf && gltf.scene) {
|
|
113
116
|
const obj = gltf.scene;
|
|
114
117
|
def.onDynamicObjectAdded(obj, prov, gltf);
|
|
@@ -118,7 +121,7 @@ export function beginListenFileSpawn(context: Context) {
|
|
|
118
121
|
|
|
119
122
|
// add object to proper parent
|
|
120
123
|
if (evt.parentGuid) {
|
|
121
|
-
const parent =
|
|
124
|
+
const parent = findByGuid(evt.parentGuid, context.scene) as THREE.Object3D;
|
|
122
125
|
if ("add" in parent) parent.add(obj);
|
|
123
126
|
}
|
|
124
127
|
if (!obj.parent)
|
|
@@ -136,7 +139,7 @@ export function beginListenFileSpawn(context: Context) {
|
|
|
136
139
|
|
|
137
140
|
|
|
138
141
|
|
|
139
|
-
async function handleUpload(connection: NetworkConnection, file: File, seed: number, obj:
|
|
142
|
+
async function handleUpload(connection: NetworkConnection, file: File, seed: number, obj: IGameObject, backendUrl: string) {
|
|
140
143
|
if (!connection.connectionId) {
|
|
141
144
|
console.error("Can not upload file - no connection id");
|
|
142
145
|
return;
|
|
@@ -180,7 +183,7 @@ function addPreview(evt: FileSpawnModel, context: Context) {
|
|
|
180
183
|
previews[evt.guid] = box;
|
|
181
184
|
context.scene.add(box);
|
|
182
185
|
if (evt.parentGuid) {
|
|
183
|
-
const parent =
|
|
186
|
+
const parent = findByGuid(evt.parentGuid, context.scene) as THREE.Object3D;
|
|
184
187
|
if (parent)
|
|
185
188
|
parent.add(box);
|
|
186
189
|
}
|
|
@@ -1,54 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
// import { SyncedTransform } from "../engine-components/SyncedTransform";
|
|
2
|
+
// import { DragControls } from "../engine-components/DragControls"
|
|
3
|
+
// import { ObjectRaycaster } from "../engine-components/ui/Raycaster";
|
|
4
|
+
import { UIDProvider } from "./engine_types";
|
|
5
5
|
import { GLTF } from "three/examples/jsm/loaders/GLTFLoader";
|
|
6
|
-
import { Animation } from "../engine-components/Animation";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
6
|
+
// import { Animation } from "../engine-components/Animation";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export function onDynamicObjectAdded(_obj: THREE.Object3D, _idProv: UIDProvider, _gltf?: GLTF) {
|
|
10
|
+
|
|
11
|
+
console.warn("Adding components on object has been temporarily disabled");
|
|
12
|
+
|
|
13
|
+
// // this ensures we have a drag component
|
|
14
|
+
// let drag = getComponentInChildren(obj as GameObject, DragControls);
|
|
15
|
+
// if (!drag) {
|
|
16
|
+
// drag = GameObject.addNewComponent(obj as GameObject, DragControls, false);
|
|
17
|
+
// drag.guid = idProv.generateUUID();
|
|
18
|
+
// }
|
|
19
|
+
|
|
20
|
+
// // if a drag component is found we add a syncedTransform if none exists
|
|
21
|
+
// if (drag && !GameObject.getComponent(drag.gameObject, SyncedTransform)) {
|
|
22
|
+
// const st = GameObject.addNewComponent(drag.gameObject, SyncedTransform, false);
|
|
23
|
+
// st.guid = idProv.generateUUID();
|
|
24
|
+
// // st.autoOwnership = true;
|
|
25
|
+
|
|
26
|
+
// //drag.transformGroup = true;
|
|
27
|
+
// //drag.targets = [obj];
|
|
28
|
+
// }
|
|
29
|
+
|
|
30
|
+
// // if a drag component is found we add a syncedTransform if none exists
|
|
31
|
+
// if (drag && !GameObject.getComponentInParent(drag.gameObject, ObjectRaycaster)) {
|
|
32
|
+
// const st = GameObject.addNewComponent(drag.gameObject, ObjectRaycaster, false);
|
|
33
|
+
// st.guid = idProv.generateUUID();
|
|
34
|
+
// }
|
|
35
|
+
|
|
36
|
+
// if (gltf) {
|
|
37
|
+
// if (gltf.animations?.length > 0) {
|
|
38
|
+
// const firstAnimation = gltf.animations[0];
|
|
39
|
+
// const anim = GameObject.addNewComponent(obj, Animation, false);
|
|
40
|
+
// anim.animations = [firstAnimation];
|
|
41
|
+
// }
|
|
42
|
+
// }
|
|
43
|
+
|
|
44
|
+
// let didDisablFrustumCulling = false;
|
|
45
|
+
// obj.traverse(o => {
|
|
46
|
+
// if (!o) return;
|
|
47
|
+
|
|
48
|
+
// if (o["isSkinnedMesh"] === true) {
|
|
49
|
+
// if (!didDisablFrustumCulling) console.log("Disabling frustum culling for skinned meshes", gltf);
|
|
50
|
+
// didDisablFrustumCulling = true;
|
|
51
|
+
// o.frustumCulled = false;
|
|
52
|
+
// }
|
|
53
|
+
|
|
54
|
+
// });
|
|
54
55
|
}
|
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
import { IModel, NetworkConnection } from "./engine_networking"
|
|
1
|
+
// import { IModel, NetworkConnection } from "./engine_networking"
|
|
2
2
|
import * as THREE from "three";
|
|
3
3
|
import { Context } from "./engine_setup"
|
|
4
|
-
import { Behaviour, Component, GameObject, InstantiateOptions, UIDProvider } from "../engine-components/Component";
|
|
5
4
|
import * as utils from "./engine_utils"
|
|
6
|
-
|
|
5
|
+
import { INetworkConnection } from "./engine_networking_types";
|
|
6
|
+
import { IGameObject as GameObject, IComponent as Component } from "./engine_types"
|
|
7
7
|
|
|
8
8
|
// https://github.com/uuidjs/uuid
|
|
9
9
|
// v5 takes string and namespace
|
|
10
10
|
import { v5, v1 } from 'uuid';
|
|
11
|
+
import { UIDProvider } from "./engine_types";
|
|
12
|
+
import { IModel } from "./engine_networking_types";
|
|
13
|
+
import { SendQueue } from "./engine_networking_types";
|
|
14
|
+
import { destroy, findByGuid, instantiate } from "./engine_gameobject";
|
|
11
15
|
import { Object3D } from "three";
|
|
12
|
-
|
|
16
|
+
import { InstantiateOptions } from "./engine_gameobject";
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const debug = utils.getParam("debugcomponents");
|
|
20
|
+
|
|
13
21
|
|
|
14
22
|
|
|
23
|
+
const ID_NAMESPACE = 'eff8ba80-635d-11ec-90d6-0242ac120003';
|
|
24
|
+
|
|
15
25
|
export class InstantiateIdProvider implements UIDProvider {
|
|
16
26
|
|
|
17
27
|
get seed() {
|
|
@@ -63,10 +73,10 @@ export interface IBeforeNetworkedDestroy {
|
|
|
63
73
|
onBeforeNetworkedDestroy(networkIds: string[]): void;
|
|
64
74
|
}
|
|
65
75
|
|
|
66
|
-
export function syncDestroy(obj: GameObject | Component, con:
|
|
76
|
+
export function syncDestroy(obj: GameObject | Component, con: INetworkConnection, recursive: boolean = true) {
|
|
67
77
|
if (!obj) return;
|
|
68
78
|
const go = obj as GameObject;
|
|
69
|
-
|
|
79
|
+
destroy(obj, recursive);
|
|
70
80
|
|
|
71
81
|
if (!con) {
|
|
72
82
|
console.warn("Can not send destroy: No networking connection provided", obj.guid);
|
|
@@ -88,12 +98,12 @@ export function syncDestroy(obj: GameObject | Component, con: NetworkConnection,
|
|
|
88
98
|
}
|
|
89
99
|
|
|
90
100
|
const model = new DestroyInstanceModel(guid);
|
|
91
|
-
con.send(InstantiateEvent.InstanceDestroyed, model);
|
|
101
|
+
con.send(InstantiateEvent.InstanceDestroyed, model, SendQueue.Queued);
|
|
92
102
|
}
|
|
93
103
|
|
|
94
|
-
export function sendDestroyed(guid: string, con:
|
|
104
|
+
export function sendDestroyed(guid: string, con: INetworkConnection) {
|
|
95
105
|
const model = new DestroyInstanceModel(guid);
|
|
96
|
-
con.send(InstantiateEvent.InstanceDestroyed, model);
|
|
106
|
+
con.send(InstantiateEvent.InstanceDestroyed, model, SendQueue.Queued);
|
|
97
107
|
}
|
|
98
108
|
|
|
99
109
|
export function beginListenDestroy(context: Context) {
|
|
@@ -101,8 +111,8 @@ export function beginListenDestroy(context: Context) {
|
|
|
101
111
|
if (debug)
|
|
102
112
|
console.log("[Remote] Destroyed", context.scene, data);
|
|
103
113
|
// TODO: create global lookup table for guids
|
|
104
|
-
const obj =
|
|
105
|
-
if (obj)
|
|
114
|
+
const obj = findByGuid(data.guid, context.scene);
|
|
115
|
+
if (obj) destroy(obj);
|
|
106
116
|
});
|
|
107
117
|
}
|
|
108
118
|
|
|
@@ -140,7 +150,7 @@ class NewInstanceModel implements IModel {
|
|
|
140
150
|
}
|
|
141
151
|
}
|
|
142
152
|
|
|
143
|
-
export function syncInstantiate(object: GameObject |
|
|
153
|
+
export function syncInstantiate(object: GameObject | Object3D, opts: InstantiateOptions, hostData?: HostData, save?: boolean): GameObject | null {
|
|
144
154
|
|
|
145
155
|
const obj: GameObject = object as GameObject;
|
|
146
156
|
|
|
@@ -226,7 +236,7 @@ export function beginListenInstantiate(context: Context) {
|
|
|
226
236
|
options.context = context;
|
|
227
237
|
if (debug && context.alias)
|
|
228
238
|
console.log("[Remote] instantiate in: " + context.alias);
|
|
229
|
-
const inst =
|
|
239
|
+
const inst = instantiate(obj as GameObject, options);
|
|
230
240
|
|
|
231
241
|
if (inst) {
|
|
232
242
|
if (model.parent === "scene")
|
|
@@ -247,7 +257,7 @@ function instantiateSeeded(obj: GameObject, opts: InstantiateOptions | null): {
|
|
|
247
257
|
const seed = generateSeed();
|
|
248
258
|
const options = opts ?? new InstantiateOptions();
|
|
249
259
|
options.idProvider = new InstantiateIdProvider(seed);
|
|
250
|
-
const instance =
|
|
260
|
+
const instance = instantiate(obj, options);
|
|
251
261
|
return { seed: seed, instance: instance };
|
|
252
262
|
}
|
|
253
263
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare interface IModel {
|
|
2
|
+
guid: string;
|
|
3
|
+
dontSave?: boolean; // if set to true the model will not be saved in the server room state
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export enum SendQueue {
|
|
8
|
+
OnConnection,
|
|
9
|
+
OnRoomJoin,
|
|
10
|
+
Queued,
|
|
11
|
+
Immediate,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export declare interface INetworkConnection {
|
|
15
|
+
get isConnected(): boolean;
|
|
16
|
+
|
|
17
|
+
send(key: string, data: IModel | object | boolean | null | string | number, queue: SendQueue): unknown;
|
|
18
|
+
|
|
19
|
+
}
|
|
@@ -2,14 +2,23 @@ import * as CANNON from 'cannon-es'
|
|
|
2
2
|
import * as THREE from 'three'
|
|
3
3
|
import { Context } from './engine_setup';
|
|
4
4
|
import cannonDebugger from 'cannon-es-debugger'
|
|
5
|
-
import { Rigidbody } from '../engine-components/Rigidbody';
|
|
6
5
|
import * as utils from "./engine_utils"
|
|
7
6
|
import * as threeutils from "./engine_three_utils"
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
import {
|
|
8
|
+
IComponent as Component,
|
|
9
|
+
IGameObject as GameObject,
|
|
10
|
+
ICollider,
|
|
11
|
+
IRigidbody as Rigidbody, $physicsKey,
|
|
12
|
+
Collision, CannonCollision,
|
|
13
|
+
ICollisionContext,
|
|
14
|
+
IComponent
|
|
15
|
+
}
|
|
16
|
+
from './engine_types';
|
|
17
|
+
import { Shape } from 'cannon-es';
|
|
12
18
|
import { InstancingUtil } from './engine_instancing';
|
|
19
|
+
import { foreachComponent } from './engine_gameobject';
|
|
20
|
+
import { getComponentInChildren } from './engine_components';
|
|
21
|
+
|
|
13
22
|
|
|
14
23
|
const debugPhysics = utils.getParam("debugphysics");
|
|
15
24
|
const debugCollisions = utils.getParam("debugcollisions");
|
|
@@ -23,7 +32,6 @@ export class BodyOptions {
|
|
|
23
32
|
sleepThreshold: number = .01;
|
|
24
33
|
}
|
|
25
34
|
|
|
26
|
-
const bodyObjectKey = Symbol("object");
|
|
27
35
|
|
|
28
36
|
// TODO: refactor to return some kind of handle for adding/removing
|
|
29
37
|
class PhysicsObject {
|
|
@@ -41,17 +49,10 @@ class PhysicsObject {
|
|
|
41
49
|
this.parent = obj.parent;
|
|
42
50
|
this.body = body;
|
|
43
51
|
if (this.body)
|
|
44
|
-
this.body[
|
|
52
|
+
this.body[$physicsKey] = obj;
|
|
45
53
|
}
|
|
46
54
|
}
|
|
47
55
|
|
|
48
|
-
declare type CannonCollision = {
|
|
49
|
-
body: CANNON.Body;
|
|
50
|
-
contact: CANNON.ContactEquation;
|
|
51
|
-
target: CANNON.Body;
|
|
52
|
-
type: string;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
56
|
export class RaycastOptions {
|
|
56
57
|
ray: THREE.Ray | undefined = undefined;
|
|
57
58
|
cam: THREE.Camera | undefined | null = undefined;
|
|
@@ -645,18 +646,20 @@ export class Physics {
|
|
|
645
646
|
// console.log("START");
|
|
646
647
|
}
|
|
647
648
|
|
|
649
|
+
private readonly collisionContext: ICollisionContext = new CollisionContext();
|
|
650
|
+
|
|
648
651
|
private raiseCollisionEvents(obj: THREE.Object3D, event: CannonCollision) {
|
|
649
|
-
const collision = new Collision(obj, event);
|
|
652
|
+
const collision = new Collision(obj, event, this.collisionContext);
|
|
650
653
|
if (debugCollisions)
|
|
651
654
|
console.log("collision between", event.contact.bi, event.contact.bj, obj, event);
|
|
652
|
-
|
|
655
|
+
foreachComponent(obj, (c: Component) => {
|
|
653
656
|
c.__internalHandleCollision(collision, false);
|
|
654
657
|
});
|
|
655
658
|
|
|
656
659
|
// handle triggers
|
|
657
660
|
if (collision.collider && !collision.collider.attachedRigidbody && collision.collider.isTrigger) {
|
|
658
|
-
const collision2 = new Collision(collision.gameObject, event, true);
|
|
659
|
-
|
|
661
|
+
const collision2 = new Collision(collision.gameObject, event, this.collisionContext, true);
|
|
662
|
+
foreachComponent(collision.gameObject, (c: Component) => {
|
|
660
663
|
c.__internalHandleCollision(collision2, true);
|
|
661
664
|
});
|
|
662
665
|
}
|
|
@@ -665,76 +668,41 @@ export class Physics {
|
|
|
665
668
|
private onEndContact(args: { bodyA: CANNON.Body, bodyB: CANNON.Body }) {
|
|
666
669
|
// if(args.bodyB.sleepState !== CANNON.Body.AWAKE) return;
|
|
667
670
|
// console.log("END", CANNON.BODY_SLEEP_STATES, args.bodyB.sleepState);
|
|
668
|
-
const obj1 = args.bodyA[
|
|
669
|
-
const obj2 = args.bodyB[
|
|
671
|
+
const obj1 = args.bodyA[$physicsKey];
|
|
672
|
+
const obj2 = args.bodyB[$physicsKey];
|
|
670
673
|
// console.log(obj2);
|
|
671
|
-
|
|
674
|
+
|
|
675
|
+
foreachComponent(obj2, (c: Component) => {
|
|
672
676
|
c.__internalHandleExitCollisionEvent(obj1, false);
|
|
673
677
|
});
|
|
674
678
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
679
|
+
// TODO: stop iterating when we found the collider
|
|
680
|
+
foreachComponent(obj1, c => {
|
|
681
|
+
const collider = c as ICollider;
|
|
682
|
+
if (collider.isCollider && !collider.attachedRigidbody && collider.isTrigger) {
|
|
683
|
+
foreachComponent(collider.gameObject, (c: Component) => {
|
|
684
|
+
c.__internalHandleExitCollisionEvent(obj2, true);
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
});
|
|
682
688
|
}
|
|
683
689
|
|
|
684
690
|
}
|
|
685
691
|
|
|
692
|
+
export interface IColliderProvider {
|
|
693
|
+
getCollider(obj: THREE.Object3D): ICollider;
|
|
694
|
+
}
|
|
686
695
|
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
get __internalInvertedSourceReceiver(): boolean {
|
|
694
|
-
return this.invert;
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
private readonly invert: boolean;
|
|
698
|
-
private readonly collision: CannonCollision;
|
|
699
|
-
private readonly targetBody: CANNON.Body;
|
|
696
|
+
let colliderProvider: IColliderProvider | null = null;
|
|
697
|
+
export function registerColliderProvider(prov: IColliderProvider) {
|
|
698
|
+
colliderProvider = prov;
|
|
699
|
+
}
|
|
700
700
|
|
|
701
|
-
|
|
701
|
+
class CollisionContext implements ICollisionContext {
|
|
702
702
|
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
if (!this._normal) {
|
|
706
|
-
const vec = this.collision.contact.ni;
|
|
707
|
-
this._normal = new Vector3(vec.x, vec.y, vec.z);
|
|
708
|
-
}
|
|
709
|
-
return this._normal;
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
private _collider?: Collider;
|
|
713
|
-
get collider(): Collider {
|
|
714
|
-
if (this._collider === undefined) {
|
|
715
|
-
this._collider = GameObject.getComponentInChildren(this.gameObject, Collider)!;
|
|
716
|
-
}
|
|
717
|
-
return this._collider;
|
|
703
|
+
getCollider(obj: THREE.Object3D<THREE.Event>): ICollider {
|
|
704
|
+
return colliderProvider!.getCollider(obj);
|
|
718
705
|
}
|
|
719
706
|
|
|
720
|
-
|
|
721
|
-
return this.targetBody[bodyObjectKey];
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
// private _point?: Vector3;
|
|
725
|
-
// get point(): Vector3 {
|
|
726
|
-
// if (!this._point) {
|
|
727
|
-
// const c = this.collision.contact;
|
|
728
|
-
// const point = c.bi.position.clone().vadd(c.ri);
|
|
729
|
-
// this._point = new Vector3(point.x, point.y, point.z);
|
|
730
|
-
// }
|
|
731
|
-
// return this._point;
|
|
732
|
-
// }
|
|
707
|
+
}
|
|
733
708
|
|
|
734
|
-
constructor(obj: Object3D, collision: CannonCollision, invert: boolean = false) {
|
|
735
|
-
this.invert = invert;
|
|
736
|
-
this.me = obj;
|
|
737
|
-
this.collision = collision;
|
|
738
|
-
this.targetBody = this.invert ? collision.target : collision.body;
|
|
739
|
-
}
|
|
740
|
-
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { SourceIdentifier } from "./engine_gltf";
|
|
2
1
|
import { Vector4, EquirectangularReflectionMapping, sRGBEncoding, WebGLCubeRenderTarget, Texture, LightProbe, Color } from "three";
|
|
3
2
|
import { LightProbeGenerator } from "three/examples/jsm/lights/LightProbeGenerator.js"
|
|
4
3
|
import { Context } from "./engine_setup";
|
|
5
4
|
import { SceneLightSettings } from "./extensions/NEEDLE_lighting_settings";
|
|
6
5
|
import { createFlatTexture, createTrilightTexture } from "./engine_shaders";
|
|
7
6
|
import { getParam } from "./engine_utils";
|
|
7
|
+
import { SourceIdentifier } from "./engine_types";
|
|
8
8
|
|
|
9
9
|
const debug = getParam("debugenvlight");
|
|
10
10
|
|
|
@@ -2,12 +2,36 @@ import { Context } from "./engine_setup"
|
|
|
2
2
|
import { Animator } from '../engine-components/Animator';
|
|
3
3
|
import { Animation } from '../engine-components/Animation';
|
|
4
4
|
import { GLTF, GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'
|
|
5
|
-
import * as object from "./engine_gltf_builtin_components";
|
|
5
|
+
// import * as object from "./engine_gltf_builtin_components";
|
|
6
6
|
import * as loaders from "./engine_loaders"
|
|
7
|
-
import { GameObject, UIDProvider } from "../engine-components/Component";
|
|
8
7
|
import * as utils from "./engine_utils";
|
|
9
8
|
import { registerComponentExtension, registerExtensions } from "./extensions/extensions";
|
|
10
|
-
import {
|
|
9
|
+
import { getLoader, INeedleGltfLoader, registerLoader } from "./engine_gltf";
|
|
10
|
+
import { SourceIdentifier, UIDProvider } from "./engine_types";
|
|
11
|
+
import { createBuiltinComponents, writeBuiltinComponentData } from "./engine_gltf_builtin_components";
|
|
12
|
+
import { SerializationContext } from "./engine_serialization_core";
|
|
13
|
+
import { NEEDLE_components } from "./extensions/NEEDLE_components";
|
|
14
|
+
import { addNewComponentInstance, getComponentInChildren } from "./engine_components";
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class NeedleGltfLoader implements INeedleGltfLoader {
|
|
18
|
+
createBuiltinComponents(context: Context, gltfId: string, gltf: any, seed: number | UIDProvider | null, extension?: NEEDLE_components | undefined) {
|
|
19
|
+
return createBuiltinComponents(context, gltfId, gltf, seed, extension);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
writeBuiltinComponentData(comp: any, context: SerializationContext) {
|
|
23
|
+
return writeBuiltinComponentData(comp, context);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
parseSync(context: Context, data, path: string, seed: number | UIDProvider | null): Promise<GLTF | undefined> {
|
|
27
|
+
return parseSync(context, data, path, seed);
|
|
28
|
+
}
|
|
29
|
+
loadSync(context: Context, url: string, seed: number | UIDProvider | null, _allowAddingAnimator: boolean, prog?: ((ProgressEvent: any) => void) | undefined): Promise<GLTF | undefined> {
|
|
30
|
+
return loadSync(context, url, seed, _allowAddingAnimator, prog);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
registerLoader(new NeedleGltfLoader());
|
|
11
35
|
|
|
12
36
|
|
|
13
37
|
const printGltf = utils.getParam("printGltf");
|
|
@@ -64,7 +88,7 @@ async function handleLoadedGltf(context: Context, gltfId: string, gltf, seed: nu
|
|
|
64
88
|
if (printGltf)
|
|
65
89
|
console.log(gltf);
|
|
66
90
|
await context.assets.registerGltf(gltf);
|
|
67
|
-
await
|
|
91
|
+
await getLoader().createBuiltinComponents(context, gltfId, gltf, seed, componentsExtension);
|
|
68
92
|
|
|
69
93
|
// load and assign animation
|
|
70
94
|
// we still need this for Animation component
|
|
@@ -151,7 +175,7 @@ export function findAnimations(gltf: GLTF, allowAddingAnimator: boolean = false)
|
|
|
151
175
|
if (!allowAddingAnimator) {
|
|
152
176
|
// we only need to search if any animation component is in the scene
|
|
153
177
|
// otherwise if we dont add anything there is no reason to search and log anything
|
|
154
|
-
if (!
|
|
178
|
+
if (!getComponentInChildren(gltf.scene, Animation)) return;
|
|
155
179
|
}
|
|
156
180
|
|
|
157
181
|
for (let i = 0; i < gltf.animations.length; i++) {
|
|
@@ -168,7 +192,7 @@ export function findAnimations(gltf: GLTF, allowAddingAnimator: boolean = false)
|
|
|
168
192
|
let animationComponent = findAnimationGameObjectInParent(obj);
|
|
169
193
|
if (!animationComponent) {
|
|
170
194
|
if (allowAddingAnimator)
|
|
171
|
-
animationComponent =
|
|
195
|
+
animationComponent = addNewComponentInstance(gltf.scene, new Animation());
|
|
172
196
|
else {
|
|
173
197
|
console.warn("Failed finding animator for", track.name, objectName);
|
|
174
198
|
continue;
|
|
@@ -3,7 +3,7 @@ import { getParam } from "./engine_utils";
|
|
|
3
3
|
import { Object3D } from "three";
|
|
4
4
|
import { Context } from "./engine_setup";
|
|
5
5
|
import { isPersistentAsset } from "./extensions/NEEDLE_persistent_assets";
|
|
6
|
-
import { SourceIdentifier } from "./
|
|
6
|
+
import { SourceIdentifier } from "./engine_types";
|
|
7
7
|
import { debugExtension } from "../engine/engine_default_parameters";
|
|
8
8
|
|
|
9
9
|
const debug = getParam("debugserializer");
|