@needle-tools/engine 2.32.0-pre → 2.33.0-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 +6 -0
- package/dist/needle-engine.d.ts +18 -11
- package/dist/needle-engine.js +341 -341
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +14 -14
- package/dist/needle-engine.min.js.map +4 -4
- package/lib/engine/extensions/NEEDLE_components.js +2 -0
- package/lib/engine/extensions/NEEDLE_components.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_techniques_webgl.d.ts +1 -0
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js +26 -0
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js.map +1 -1
- package/lib/engine-components/Collider.js +2 -2
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Component.js +2 -50
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/ScreenCapture.d.ts +8 -4
- package/lib/engine-components/ScreenCapture.js +73 -18
- package/lib/engine-components/ScreenCapture.js.map +1 -1
- package/lib/engine-components/codegen/{exports.d.ts → components.d.ts} +2 -1
- package/lib/engine-components/codegen/{exports.js → components.js} +3 -2
- package/lib/engine-components/codegen/components.js.map +1 -0
- package/lib/engine-components/js-extensions/Object3D.d.ts +2 -0
- package/lib/engine-components/js-extensions/Object3D.js +75 -0
- package/lib/engine-components/js-extensions/Object3D.js.map +1 -0
- package/lib/needle-engine.d.ts +2 -1
- package/lib/needle-engine.js +3 -2
- package/lib/needle-engine.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/codegen/register_types.js +4 -4
- package/src/engine/extensions/NEEDLE_components.ts +3 -0
- package/src/engine/extensions/NEEDLE_techniques_webgl.ts +34 -2
- package/src/engine-components/Collider.ts +2 -2
- package/src/engine-components/Component.ts +2 -63
- package/src/engine-components/ScreenCapture.ts +73 -20
- package/src/engine-components/codegen/{exports.ts → components.ts} +1 -1
- package/src/engine-components/js-extensions/Object3D.ts +91 -0
- package/src/needle-engine.ts +3 -3
- package/lib/engine-components/ComponentExtensions.d.ts +0 -2
- package/lib/engine-components/ComponentExtensions.js +0 -3
- package/lib/engine-components/ComponentExtensions.js.map +0 -1
- package/lib/engine-components/codegen/exports.js.map +0 -1
- package/src/engine-components/ComponentExtensions.ts +0 -7
|
@@ -10,6 +10,7 @@ import { Object3D } from "three";
|
|
|
10
10
|
import { InstantiateIdProvider, syncDestroy, syncInstantiate } from "../engine/engine_networking_instantiate";
|
|
11
11
|
import { SourceIdentifier } from "../engine/engine_gltf";
|
|
12
12
|
import { Collision } from "../engine/engine_physics";
|
|
13
|
+
import * as Object3DExtensions from "./js-extensions/Object3D";
|
|
13
14
|
|
|
14
15
|
export interface UIDProvider {
|
|
15
16
|
seed: number;
|
|
@@ -70,10 +71,6 @@ declare class NewGameObjectReferenceInfo {
|
|
|
70
71
|
clone: THREE.Object3D;
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
THREE.Object3D.prototype["SetActive"] = function (active: boolean) {
|
|
74
|
-
this.visible = active;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
74
|
|
|
78
75
|
abstract class GameObject extends THREE.Object3D implements THREE.Object3D {
|
|
79
76
|
|
|
@@ -217,6 +214,7 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D {
|
|
|
217
214
|
instance.children = [];
|
|
218
215
|
let clone: THREE.Object3D | GameObject;
|
|
219
216
|
clone = instance.clone(false);
|
|
217
|
+
Object3DExtensions.apply(clone);
|
|
220
218
|
instance.userData = userData;
|
|
221
219
|
instance.children = children;
|
|
222
220
|
|
|
@@ -684,65 +682,6 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D {
|
|
|
684
682
|
}
|
|
685
683
|
|
|
686
684
|
|
|
687
|
-
// this is a fix to allow gameObject active animation be applied to a three object
|
|
688
|
-
Object.defineProperty(THREE.Object3D.prototype, "activeSelf", {
|
|
689
|
-
get: function () {
|
|
690
|
-
return this.visible;
|
|
691
|
-
},
|
|
692
|
-
set: function (val: boolean | number) {
|
|
693
|
-
const state = typeof val === "number" ? val > 0.5 : val;
|
|
694
|
-
this.visible = state;
|
|
695
|
-
}
|
|
696
|
-
});
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
THREE.Object3D.prototype["addNewComponent"] = function <T extends Behaviour>(type: ConstructorConcrete<T>) {
|
|
700
|
-
return GameObject.addNewComponent(this, type);
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
THREE.Object3D.prototype["removeComponent"] = function (inst: Component) {
|
|
704
|
-
return GameObject.removeComponent(inst);
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
THREE.Object3D.prototype["getOrAddComponent"] = function <T>(typeName: Constructor<T> | null): T {
|
|
708
|
-
return GameObject.getOrAddComponent(this, typeName);
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
THREE.Object3D.prototype["getComponent"] = function <T>(type: Constructor<T>) {
|
|
712
|
-
return GameObject.getComponent(this, type);
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
THREE.Object3D.prototype["getComponents"] = function <T>(type: Constructor<T>, arr?: []) {
|
|
716
|
-
return GameObject.getComponents(this, type, arr);
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
THREE.Object3D.prototype["getComponentInChildren"] = function <T>(type: Constructor<T>) {
|
|
720
|
-
return GameObject.getComponentInChildren(this, type);
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
THREE.Object3D.prototype["getComponentsInChildren"] = function <T>(type: Constructor<T>, arr?: []) {
|
|
724
|
-
return GameObject.getComponentsInChildren(this, type, arr);
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
THREE.Object3D.prototype["getComponentInParent"] = function <T>(type: Constructor<T>) {
|
|
728
|
-
return GameObject.getComponentInParent(this, type);
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
THREE.Object3D.prototype["getComponentsInParent"] = function <T>(type: Constructor<T>, arr?: []) {
|
|
732
|
-
return GameObject.getComponentsInParent(this, type, arr);
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
// function patch_THREEObject3D() {
|
|
736
|
-
// const props = Object.getOwnPropertyNames(GameObject.prototype);
|
|
737
|
-
// for (const propName in props) {
|
|
738
|
-
// const prop = props[propName];
|
|
739
|
-
// if (prop === "constructor") continue;
|
|
740
|
-
// const fn = GameObject.prototype[prop];
|
|
741
|
-
// THREE.Object3D.prototype[prop] = fn;
|
|
742
|
-
// }
|
|
743
|
-
// }
|
|
744
|
-
// patch_THREEObject3D();
|
|
745
|
-
|
|
746
685
|
|
|
747
686
|
class Component implements EventTarget {
|
|
748
687
|
|
|
@@ -10,11 +10,14 @@ import { IPointerClickHandler } from "./ui/PointerEvents";
|
|
|
10
10
|
import { EventDispatcher } from "three";
|
|
11
11
|
import { AudioSource } from "./AudioSource";
|
|
12
12
|
import { getWorldScale, setWorldScale } from "../engine/engine_three_utils";
|
|
13
|
+
import { getParam } from "../engine/engine_utils";
|
|
13
14
|
|
|
15
|
+
const debug = getParam("debugscreenshare");
|
|
14
16
|
|
|
15
17
|
export enum ScreenCaptureDevice {
|
|
16
18
|
Screen = 0,
|
|
17
|
-
Camera = 1
|
|
19
|
+
Camera = 1,
|
|
20
|
+
Canvas = 2
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
export enum ScreenCaptureMode {
|
|
@@ -38,6 +41,9 @@ function disposeStream(str: MediaStream | null | undefined) {
|
|
|
38
41
|
export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
39
42
|
|
|
40
43
|
onPointerClick() {
|
|
44
|
+
if (this.isReceiving) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
41
47
|
if (this.isSending) {
|
|
42
48
|
this.close();
|
|
43
49
|
return;
|
|
@@ -46,7 +52,8 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
|
|
49
|
-
|
|
55
|
+
@serializeable(VideoPlayer)
|
|
56
|
+
videoPlayer?: VideoPlayer;
|
|
50
57
|
|
|
51
58
|
@serializeable()
|
|
52
59
|
device: ScreenCaptureDevice = ScreenCaptureDevice.Screen;
|
|
@@ -54,32 +61,49 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
54
61
|
@serializeable()
|
|
55
62
|
aspectMode: AspectMode = AspectMode.AdjustHeight;
|
|
56
63
|
|
|
64
|
+
get currentScream(): MediaStream | null {
|
|
65
|
+
return this._currentStream;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get currentMode(): ScreenCaptureMode {
|
|
69
|
+
return this._currentMode;
|
|
70
|
+
}
|
|
57
71
|
|
|
58
72
|
get isSending() {
|
|
59
|
-
return this._currentStream && this._currentMode === ScreenCaptureMode.Sending;
|
|
73
|
+
return this._currentStream?.active && this._currentMode === ScreenCaptureMode.Sending;
|
|
60
74
|
}
|
|
61
75
|
get isReceiving() {
|
|
62
|
-
|
|
76
|
+
if (this._currentMode === ScreenCaptureMode.Receiving) {
|
|
77
|
+
if (!this._currentStream || this._currentStream.active === false) return false;
|
|
78
|
+
// if any track is still live consider it active
|
|
79
|
+
const tracks = this._currentStream.getTracks();
|
|
80
|
+
for (const track of tracks) {
|
|
81
|
+
if (track.readyState === "live") return true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
63
85
|
}
|
|
64
86
|
|
|
65
87
|
private _net?: NetworkedVideo;
|
|
66
|
-
private _video?: VideoPlayer;
|
|
67
88
|
private _requestOpen: boolean = false;
|
|
68
89
|
private _currentStream: MediaStream | null = null;
|
|
69
90
|
private _currentMode: ScreenCaptureMode = ScreenCaptureMode.Idle;
|
|
70
91
|
|
|
71
92
|
awake() {
|
|
93
|
+
console.log(this);
|
|
72
94
|
AudioSource.registerWaitForAllowAudio(() => {
|
|
73
|
-
if (this.
|
|
74
|
-
this.
|
|
95
|
+
if (this.videoPlayer && this._currentStream && this._currentMode === ScreenCaptureMode.Receiving) {
|
|
96
|
+
this.videoPlayer.setVideo(this._currentStream);
|
|
75
97
|
}
|
|
76
98
|
});
|
|
77
99
|
}
|
|
78
100
|
|
|
79
101
|
start() {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
102
|
+
if (!this.videoPlayer) {
|
|
103
|
+
this.videoPlayer = GameObject.getComponent(this.gameObject, VideoPlayer) ?? undefined;
|
|
104
|
+
}
|
|
105
|
+
if (!this.videoPlayer) {
|
|
106
|
+
console.error("Screencapture did not find a VideoPlayer component");
|
|
83
107
|
return;
|
|
84
108
|
}
|
|
85
109
|
const handle = PeerHandle.getOrCreate(this.context, this.guid);
|
|
@@ -92,7 +116,7 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
92
116
|
async share() {
|
|
93
117
|
this._requestOpen = true;
|
|
94
118
|
try {
|
|
95
|
-
if (this.
|
|
119
|
+
if (this.videoPlayer) {
|
|
96
120
|
|
|
97
121
|
const settings: MediaTrackConstraints = {
|
|
98
122
|
echoCancellation: true,
|
|
@@ -104,10 +128,12 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
104
128
|
};
|
|
105
129
|
|
|
106
130
|
switch (this.device) {
|
|
131
|
+
// Capture a connected camera
|
|
107
132
|
case ScreenCaptureDevice.Camera:
|
|
108
133
|
this.tryShareUserCamera(displayMediaOptions);
|
|
109
134
|
break;
|
|
110
135
|
|
|
136
|
+
// capture any screen, will show a popup
|
|
111
137
|
case ScreenCaptureDevice.Screen:
|
|
112
138
|
if (!navigator.mediaDevices.getDisplayMedia) {
|
|
113
139
|
console.error("No getDisplayMedia support");
|
|
@@ -119,6 +145,16 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
119
145
|
}
|
|
120
146
|
else disposeStream(myVideo);
|
|
121
147
|
break;
|
|
148
|
+
|
|
149
|
+
// capture the canvas meaning the threejs view
|
|
150
|
+
case ScreenCaptureDevice.Canvas:
|
|
151
|
+
// looks like this doesnt work reliably on chrome https://stackoverflow.com/a/66848674
|
|
152
|
+
// firefox updates fine
|
|
153
|
+
// https://bugs.chromium.org/p/chromium/issues/detail?id=1156408
|
|
154
|
+
const fps = 0;
|
|
155
|
+
const stream = this.context.renderer.domElement.captureStream(fps);
|
|
156
|
+
this.setVideo(stream, ScreenCaptureMode.Sending);
|
|
157
|
+
break;
|
|
122
158
|
}
|
|
123
159
|
}
|
|
124
160
|
} catch (err: any) {
|
|
@@ -136,8 +172,8 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
136
172
|
this._requestOpen = false;
|
|
137
173
|
if (this._currentStream) {
|
|
138
174
|
console.warn("Close current stream / disposing resources");
|
|
139
|
-
disposeStream(this._currentStream);
|
|
140
175
|
this._net?.stopSendingVideo(this._currentStream);
|
|
176
|
+
disposeStream(this._currentStream);
|
|
141
177
|
this._currentMode = ScreenCaptureMode.Idle;
|
|
142
178
|
this._currentStream = null;
|
|
143
179
|
}
|
|
@@ -146,11 +182,11 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
146
182
|
private setVideo(stream: MediaStream, mode: ScreenCaptureMode) {
|
|
147
183
|
if (stream === this._currentStream) return;
|
|
148
184
|
this.close();
|
|
149
|
-
if (!stream || !this.
|
|
185
|
+
if (!stream || !this.videoPlayer) return;
|
|
150
186
|
this._currentStream = stream;
|
|
151
187
|
this._requestOpen = true;
|
|
152
188
|
this._currentMode = mode;
|
|
153
|
-
this.
|
|
189
|
+
this.videoPlayer.setVideo(stream);
|
|
154
190
|
if (mode === ScreenCaptureMode.Sending)
|
|
155
191
|
this._net?.startSendingVideo(stream);
|
|
156
192
|
|
|
@@ -204,7 +240,7 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
204
240
|
|
|
205
241
|
// }
|
|
206
242
|
|
|
207
|
-
|
|
243
|
+
|
|
208
244
|
|
|
209
245
|
|
|
210
246
|
private _targetObjects?: Array<THREE.Object3D>;
|
|
@@ -216,20 +252,34 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
216
252
|
private _updateAspectRoutineId: number = -1;
|
|
217
253
|
private *updateAspectImpl() {
|
|
218
254
|
const id = ++this._updateAspectRoutineId;
|
|
255
|
+
const lastAspect: number | undefined = undefined;
|
|
219
256
|
while (this.aspectMode !== AspectMode.None && this._currentStream && id === this._updateAspectRoutineId) {
|
|
220
|
-
const video = this.
|
|
257
|
+
const video = this.videoPlayer;
|
|
221
258
|
const stream = this._currentStream;
|
|
222
259
|
if (!video) return;
|
|
223
260
|
if (!stream) return;
|
|
224
261
|
let aspect: number | undefined = undefined;
|
|
225
262
|
for (const track of stream.getVideoTracks()) {
|
|
226
263
|
const settings = track.getSettings();
|
|
227
|
-
if (settings.width && settings.height) {
|
|
264
|
+
if (settings && settings.width && settings.height) {
|
|
228
265
|
aspect = settings.width / settings.height;
|
|
229
266
|
break;
|
|
230
267
|
}
|
|
268
|
+
// on firefox capture canvas stream works but looks like
|
|
269
|
+
// the canvas stream track doesnt contain settings?!!?
|
|
270
|
+
else {
|
|
271
|
+
if (this.device === ScreenCaptureDevice.Canvas)
|
|
272
|
+
aspect = this.context.renderer.domElement.clientWidth / this.context.renderer.domElement.clientHeight;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (aspect === undefined) {
|
|
276
|
+
yield;
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
if (lastAspect === aspect) {
|
|
280
|
+
yield;
|
|
281
|
+
continue;
|
|
231
282
|
}
|
|
232
|
-
if (aspect === undefined) return;
|
|
233
283
|
if (!this._targetObjects)
|
|
234
284
|
this._targetObjects = video.getTargetObjects();
|
|
235
285
|
for (const obj of this._targetObjects) {
|
|
@@ -247,7 +297,8 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
247
297
|
break;
|
|
248
298
|
}
|
|
249
299
|
}
|
|
250
|
-
|
|
300
|
+
for (let i = 0; i < 3; i++)
|
|
301
|
+
yield;
|
|
251
302
|
}
|
|
252
303
|
}
|
|
253
304
|
}
|
|
@@ -444,7 +495,8 @@ class PeerHandle extends EventDispatcher {
|
|
|
444
495
|
}
|
|
445
496
|
|
|
446
497
|
private onPeerConnect(id): void {
|
|
447
|
-
|
|
498
|
+
if (debug)
|
|
499
|
+
console.log("Peer connected as", id);
|
|
448
500
|
this.context.connection.send(PeerEvent.Connected, new PeerUserConnectedModel(this, id));
|
|
449
501
|
}
|
|
450
502
|
|
|
@@ -539,6 +591,7 @@ class NetworkedVideo extends EventDispatcher {
|
|
|
539
591
|
if (_steam) {
|
|
540
592
|
const calls = this._sendingVideoStreams.get(_steam);
|
|
541
593
|
if (calls) {
|
|
594
|
+
console.log("Closing calls", calls);
|
|
542
595
|
for (const call of calls) {
|
|
543
596
|
call.close();
|
|
544
597
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Export types
|
|
2
|
+
export class __Ignore {}
|
|
2
3
|
export { AlignmentConstraint } from "../AlignmentConstraint";
|
|
3
4
|
export { Animation } from "../Animation";
|
|
4
5
|
export { AnimationCurve } from "../AnimationCurve";
|
|
@@ -16,7 +17,6 @@ export { Collider } from "../Collider";
|
|
|
16
17
|
export { SphereCollider } from "../Collider";
|
|
17
18
|
export { BoxCollider } from "../Collider";
|
|
18
19
|
export { InstantiateOptions } from "../Component";
|
|
19
|
-
export { UnityObject } from "../ComponentExtensions";
|
|
20
20
|
export { DeleteBox } from "../DeleteBox";
|
|
21
21
|
export { Deletable } from "../DeleteBox";
|
|
22
22
|
export { DeviceFlag } from "../DeviceFlag";
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Object3D } from "three";
|
|
2
|
+
import { Behaviour, Component, Constructor, ConstructorConcrete, GameObject } from "../Component";
|
|
3
|
+
|
|
4
|
+
const decorated = Symbol("GameObject.decorated");
|
|
5
|
+
|
|
6
|
+
// this is a fix to allow gameObject active animation be applied to a three object
|
|
7
|
+
Object.defineProperty(Object3D.prototype, "activeSelf", {
|
|
8
|
+
get: function () {
|
|
9
|
+
return this.visible;
|
|
10
|
+
},
|
|
11
|
+
set: function (val: boolean | number) {
|
|
12
|
+
const state = typeof val === "number" ? val > 0.5 : val;
|
|
13
|
+
this.visible = state;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
// do we still need this?
|
|
19
|
+
Object3D.prototype["SetActive"] = function (active: boolean) {
|
|
20
|
+
this.visible = active;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
Object3D.prototype["addNewComponent"] = function <T extends Behaviour>(type: ConstructorConcrete<T>) {
|
|
24
|
+
return GameObject.addNewComponent(this, type);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
Object3D.prototype["removeComponent"] = function (inst: Component) {
|
|
28
|
+
return GameObject.removeComponent(inst);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
Object3D.prototype["getOrAddComponent"] = function <T>(typeName: Constructor<T> | null): T {
|
|
32
|
+
return GameObject.getOrAddComponent(this, typeName);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
Object3D.prototype["getComponent"] = function <T>(type: Constructor<T>) {
|
|
36
|
+
return GameObject.getComponent(this, type);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
Object3D.prototype["getComponents"] = function <T>(type: Constructor<T>, arr?: []) {
|
|
40
|
+
return GameObject.getComponents(this, type, arr);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
Object3D.prototype["getComponentInChildren"] = function <T>(type: Constructor<T>) {
|
|
44
|
+
return GameObject.getComponentInChildren(this, type);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
Object3D.prototype["getComponentsInChildren"] = function <T>(type: Constructor<T>, arr?: []) {
|
|
48
|
+
return GameObject.getComponentsInChildren(this, type, arr);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
Object3D.prototype["getComponentInParent"] = function <T>(type: Constructor<T>) {
|
|
52
|
+
return GameObject.getComponentInParent(this, type);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
Object3D.prototype["getComponentsInParent"] = function <T>(type: Constructor<T>, arr?: []) {
|
|
56
|
+
return GameObject.getComponentsInParent(this, type, arr);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
// used to decorate cloned object3D objects with the same added components defined above
|
|
61
|
+
const extensions = Object.keys(Object3D.prototype);
|
|
62
|
+
const descriptors = new Array<PropertyDescriptor | undefined>();
|
|
63
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
64
|
+
const key = extensions[i];
|
|
65
|
+
const descriptor = Object.getOwnPropertyDescriptor(Object3D.prototype, key);
|
|
66
|
+
if (descriptor) {
|
|
67
|
+
descriptors.push(descriptor);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function apply(object: Object3D) {
|
|
72
|
+
if (object[decorated]) return;
|
|
73
|
+
object[decorated] = true;
|
|
74
|
+
|
|
75
|
+
// const prototype = object.constructor.prototype;
|
|
76
|
+
|
|
77
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
78
|
+
const key = extensions[i];
|
|
79
|
+
const desc = descriptors[i];
|
|
80
|
+
if (desc) {
|
|
81
|
+
// if (prototype) {
|
|
82
|
+
// const exists = Object.getOwnPropertyDescriptor(prototype, key);
|
|
83
|
+
// if (exists) {
|
|
84
|
+
// continue;
|
|
85
|
+
// }
|
|
86
|
+
// }
|
|
87
|
+
// console.trace("DEFINE", object.name, key);
|
|
88
|
+
Object.defineProperty(object, key, desc);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
package/src/needle-engine.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import "./engine/engine_element";
|
|
2
2
|
import "./engine/engine_setup";
|
|
3
|
+
import * as Components from "./engine-components/codegen/components";
|
|
3
4
|
// import "./engine/engine_mainloop";
|
|
4
5
|
// import "./engine-components/DomOverlay";
|
|
5
6
|
|
|
6
7
|
export { GameObject, Behaviour } from "./engine-components/Component";
|
|
7
8
|
export { serializeable } from "./engine/engine_serialization_decorator";
|
|
8
9
|
export { Collision } from "./engine/engine_physics";
|
|
9
|
-
export * from "./engine-components/codegen/
|
|
10
|
-
|
|
10
|
+
export * from "./engine-components/codegen/components";
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
export * from "./engine-components/js-extensions/Object3D";
|
|
13
14
|
|
|
14
15
|
// make accessible for external javascript
|
|
15
16
|
import { Context } from "./engine/engine_setup";
|
|
@@ -21,7 +22,6 @@ function registerGlobal(obj: object) {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
import * as Component from "./engine-components/Component";
|
|
24
|
-
import * as Components from "./engine-components/codegen/exports";
|
|
25
25
|
registerGlobal(Component);
|
|
26
26
|
registerGlobal(Components);
|
|
27
27
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentExtensions.js","sourceRoot":"","sources":["../../../engine-components/ComponentExtensions.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,WAAW;CAEvB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../../../engine-components/codegen/exports.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C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