@needle-tools/engine 2.35.2-pre → 2.35.3-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 +7 -0
- package/dist/needle-engine.d.ts +315 -291
- package/dist/needle-engine.js +3339 -230
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +34 -34
- package/dist/needle-engine.min.js.map +4 -4
- package/lib/engine/engine.d.ts +1 -0
- package/lib/engine/engine_components.js +5 -0
- package/lib/engine/engine_components.js.map +1 -1
- package/lib/engine/engine_element.d.ts +2 -1
- package/lib/engine/engine_element.js +4 -1
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_gltf.d.ts +2 -2
- package/lib/engine/engine_gltf.js +5 -1
- package/lib/engine/engine_gltf.js.map +1 -1
- package/lib/engine/engine_scenetools.d.ts +9 -0
- package/lib/engine/engine_scenetools.js +2 -2
- package/lib/engine/engine_scenetools.js.map +1 -1
- package/lib/engine/engine_types.d.ts +5 -0
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_deferred_texture.js +33 -1
- package/lib/engine/extensions/NEEDLE_deferred_texture.js.map +1 -1
- package/lib/engine-components/Component.js +5 -1
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/DragControls.d.ts +1 -0
- package/lib/engine-components/DragControls.js +11 -6
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/Renderer.js +2 -2
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/ScreenCapture.d.ts +7 -1
- package/lib/engine-components/ScreenCapture.js +12 -5
- package/lib/engine-components/ScreenCapture.js.map +1 -1
- package/lib/engine-components/WebXR.d.ts +1 -1
- package/lib/engine-components/WebXR.js +12 -8
- package/lib/engine-components/WebXR.js.map +1 -1
- package/lib/engine-components/js-extensions/ExtensionUtils.d.ts +3 -1
- package/lib/engine-components/js-extensions/ExtensionUtils.js +18 -8
- package/lib/engine-components/js-extensions/ExtensionUtils.js.map +1 -1
- package/lib/engine-components/js-extensions/Object3D.js +18 -15
- package/lib/engine-components/js-extensions/Object3D.js.map +1 -1
- package/lib/engine-components/js-extensions/Vector.js +3 -3
- package/lib/engine-components/js-extensions/Vector.js.map +1 -1
- package/package.json +10 -1
- package/src/engine/engine_components.ts +5 -0
- package/src/engine/engine_element.ts +7 -2
- package/src/engine/engine_gltf.ts +8 -4
- package/src/engine/engine_scenetools.ts +2 -2
- package/src/engine/engine_types.ts +10 -6
- package/src/engine/extensions/NEEDLE_deferred_texture.ts +36 -3
- package/src/engine-components/Component.ts +7 -1
- package/src/engine-components/DragControls.ts +10 -8
- package/src/engine-components/Renderer.ts +2 -2
- package/src/engine-components/ScreenCapture.ts +20 -5
- package/src/engine-components/WebXR.ts +17 -11
- package/src/engine-components/js-extensions/ExtensionUtils.ts +27 -12
- package/src/engine-components/js-extensions/Object3D.ts +23 -16
- package/src/engine-components/js-extensions/Vector.ts +6 -4
|
@@ -1,19 +1,32 @@
|
|
|
1
|
+
import { Object3D } from "three";
|
|
2
|
+
import { Constructor } from "../../engine/engine_types";
|
|
1
3
|
|
|
2
|
-
const handlers
|
|
4
|
+
const handlers: Map<any, ApplyPrototypeExtension> = new Map();
|
|
3
5
|
|
|
4
|
-
export function applyPrototypeExtensions(obj :
|
|
5
|
-
if(!obj) return;
|
|
6
|
-
const prototype = obj
|
|
7
|
-
|
|
6
|
+
export function applyPrototypeExtensions<T>(obj: any, prototype : Constructor<T>) {
|
|
7
|
+
if (!obj) return;
|
|
8
|
+
// const prototype = Object.getPrototypeOf(obj);
|
|
9
|
+
// console.log("TEST", prototype)
|
|
10
|
+
if (!prototype) {
|
|
11
|
+
console.warn("No prototype found", obj, obj.prototype, obj.constructor);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
8
14
|
let handler = handlers.get(prototype);
|
|
9
|
-
if(
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
if (handler) {
|
|
16
|
+
// console.log("OK", prototype);
|
|
17
|
+
handler.apply(obj);
|
|
12
18
|
}
|
|
13
|
-
|
|
19
|
+
// applyPrototypeExtensions(prototype);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function registerPrototypeExtensions<T>(type: Constructor<T>) {
|
|
23
|
+
console.log("Register", type.prototype.constructor.name);
|
|
24
|
+
const handler = createPrototypeExtensionHandler(type.prototype);
|
|
25
|
+
handlers.set(type, handler);
|
|
14
26
|
}
|
|
15
27
|
|
|
16
|
-
|
|
28
|
+
|
|
29
|
+
function createPrototypeExtensionHandler(prototype: any) {
|
|
17
30
|
return new ApplyPrototypeExtension(prototype);
|
|
18
31
|
}
|
|
19
32
|
|
|
@@ -31,9 +44,11 @@ class ApplyPrototypeExtension implements IApplyPrototypeExtension {
|
|
|
31
44
|
this.$symbol = Symbol("prototype-extension");
|
|
32
45
|
// used to decorate cloned object3D objects with the same added components defined above
|
|
33
46
|
this.extensions = Object.keys(prototype);
|
|
47
|
+
// console.log(this.extensions);
|
|
34
48
|
this.descriptors = new Array<PropertyDescriptor | undefined>();
|
|
35
49
|
for (let i = 0; i < this.extensions.length; i++) {
|
|
36
50
|
const key = this.extensions[i];
|
|
51
|
+
// console.log(key);
|
|
37
52
|
const descriptor = Object.getOwnPropertyDescriptor(prototype, key);
|
|
38
53
|
if (descriptor) {
|
|
39
54
|
this.descriptors.push(descriptor);
|
|
@@ -41,7 +56,7 @@ class ApplyPrototypeExtension implements IApplyPrototypeExtension {
|
|
|
41
56
|
}
|
|
42
57
|
}
|
|
43
58
|
|
|
44
|
-
apply(object:
|
|
59
|
+
apply(object: Object3D): void {
|
|
45
60
|
|
|
46
61
|
if (object[this.$symbol]) return;
|
|
47
62
|
object[this.$symbol] = true;
|
|
@@ -58,7 +73,7 @@ class ApplyPrototypeExtension implements IApplyPrototypeExtension {
|
|
|
58
73
|
// continue;
|
|
59
74
|
// }
|
|
60
75
|
// }
|
|
61
|
-
// console.
|
|
76
|
+
// console.warn("DEFINE", object, key);
|
|
62
77
|
Object.defineProperty(object, key, desc);
|
|
63
78
|
}
|
|
64
79
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { applyPrototypeExtensions } from "./ExtensionUtils";
|
|
1
|
+
import { applyPrototypeExtensions, registerPrototypeExtensions } from "./ExtensionUtils";
|
|
2
2
|
import { Object3D } from "three";
|
|
3
3
|
import { Constructor, ConstructorConcrete, IComponent } from "../../engine/engine_types"
|
|
4
4
|
import { IComponent as Component } from "../../engine/engine_types";
|
|
@@ -6,24 +6,12 @@ import { addNewComponentInstance, getComponent, getComponentInChildren, getCompo
|
|
|
6
6
|
|
|
7
7
|
// used to decorate cloned object3D objects with the same added components defined above
|
|
8
8
|
export function apply(object: Object3D) {
|
|
9
|
-
if (object && object.isObject3D === true)
|
|
10
|
-
applyPrototypeExtensions(object);
|
|
9
|
+
if (object && object.isObject3D === true) {
|
|
10
|
+
applyPrototypeExtensions(object, Object3D);
|
|
11
|
+
}
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
|
|
14
|
-
// this is a fix to allow gameObject active animation be applied to a three object
|
|
15
|
-
if (!Object.getOwnPropertyDescriptor(Object3D.prototype, "activeSelf")) {
|
|
16
|
-
Object.defineProperty(Object3D.prototype, "activeSelf", {
|
|
17
|
-
get: function () {
|
|
18
|
-
return this.visible;
|
|
19
|
-
},
|
|
20
|
-
set: function (val: boolean | number) {
|
|
21
|
-
const state = typeof val === "number" ? val > 0.5 : val;
|
|
22
|
-
this.visible = state;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
15
|
|
|
28
16
|
// do we still need this?
|
|
29
17
|
Object3D.prototype["SetActive"] = function (active: boolean) {
|
|
@@ -65,3 +53,22 @@ Object3D.prototype["getComponentInParent"] = function <T extends IComponent>(typ
|
|
|
65
53
|
Object3D.prototype["getComponentsInParent"] = function <T>(type: Constructor<T>, arr?: []) {
|
|
66
54
|
return getComponentsInParent(this, type, arr);
|
|
67
55
|
}
|
|
56
|
+
|
|
57
|
+
// this is a fix to allow gameObject active animation be applied to a three object
|
|
58
|
+
if (!Object.getOwnPropertyDescriptor(Object3D.prototype, "activeSelf")) {
|
|
59
|
+
Object.defineProperty(Object3D.prototype, "activeSelf", {
|
|
60
|
+
get: function () {
|
|
61
|
+
return this.visible;
|
|
62
|
+
},
|
|
63
|
+
set: function (val: boolean | number) {
|
|
64
|
+
const state = typeof val === "number" ? val > 0.5 : val;
|
|
65
|
+
this.visible = state;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
// do this after adding the component extensions
|
|
74
|
+
registerPrototypeExtensions(Object3D);
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { applyPrototypeExtensions } from "./ExtensionUtils";
|
|
1
|
+
import { applyPrototypeExtensions, registerPrototypeExtensions } from "./ExtensionUtils";
|
|
2
2
|
import { Mathf } from "../../engine/engine_math";
|
|
3
3
|
import { Vector3 } from "three";
|
|
4
4
|
|
|
5
5
|
export function apply(object: Vector3) {
|
|
6
6
|
if (object && object.isVector3 === true) {
|
|
7
|
-
|
|
8
|
-
applyPrototypeExtensions(object);
|
|
7
|
+
applyPrototypeExtensions(object, Vector3);
|
|
9
8
|
}
|
|
10
9
|
}
|
|
11
10
|
|
|
11
|
+
|
|
12
12
|
Vector3.prototype["slerp"] = function (end: Vector3, t: number) {
|
|
13
13
|
const len1 = this.length();
|
|
14
14
|
const len2 = end.length();
|
|
15
15
|
const targetLen = Mathf.lerp(len1, len2, t);
|
|
16
16
|
return this.lerp(end, t).normalize().multiplyScalar(targetLen);
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
registerPrototypeExtensions(Vector3);
|