@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,22 +1,11 @@
|
|
|
1
|
-
import { applyPrototypeExtensions } from "./ExtensionUtils";
|
|
1
|
+
import { applyPrototypeExtensions, registerPrototypeExtensions } from "./ExtensionUtils";
|
|
2
2
|
import { Object3D } from "three";
|
|
3
3
|
import { addNewComponentInstance, getComponent, getComponentInChildren, getComponentInParent, getComponents, getComponentsInChildren, getComponentsInParent, getOrAddComponent, removeComponent } from "../../engine/engine_components";
|
|
4
4
|
// used to decorate cloned object3D objects with the same added components defined above
|
|
5
5
|
export function apply(object) {
|
|
6
|
-
if (object && object.isObject3D === true)
|
|
7
|
-
applyPrototypeExtensions(object);
|
|
8
|
-
}
|
|
9
|
-
// this is a fix to allow gameObject active animation be applied to a three object
|
|
10
|
-
if (!Object.getOwnPropertyDescriptor(Object3D.prototype, "activeSelf")) {
|
|
11
|
-
Object.defineProperty(Object3D.prototype, "activeSelf", {
|
|
12
|
-
get: function () {
|
|
13
|
-
return this.visible;
|
|
14
|
-
},
|
|
15
|
-
set: function (val) {
|
|
16
|
-
const state = typeof val === "number" ? val > 0.5 : val;
|
|
17
|
-
this.visible = state;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
6
|
+
if (object && object.isObject3D === true) {
|
|
7
|
+
applyPrototypeExtensions(object, Object3D);
|
|
8
|
+
}
|
|
20
9
|
}
|
|
21
10
|
// do we still need this?
|
|
22
11
|
Object3D.prototype["SetActive"] = function (active) {
|
|
@@ -49,4 +38,18 @@ Object3D.prototype["getComponentInParent"] = function (type) {
|
|
|
49
38
|
Object3D.prototype["getComponentsInParent"] = function (type, arr) {
|
|
50
39
|
return getComponentsInParent(this, type, arr);
|
|
51
40
|
};
|
|
41
|
+
// this is a fix to allow gameObject active animation be applied to a three object
|
|
42
|
+
if (!Object.getOwnPropertyDescriptor(Object3D.prototype, "activeSelf")) {
|
|
43
|
+
Object.defineProperty(Object3D.prototype, "activeSelf", {
|
|
44
|
+
get: function () {
|
|
45
|
+
return this.visible;
|
|
46
|
+
},
|
|
47
|
+
set: function (val) {
|
|
48
|
+
const state = typeof val === "number" ? val > 0.5 : val;
|
|
49
|
+
this.visible = state;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// do this after adding the component extensions
|
|
54
|
+
registerPrototypeExtensions(Object3D);
|
|
52
55
|
//# sourceMappingURL=Object3D.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Object3D.js","sourceRoot":"","sources":["../../../../engine-components/js-extensions/Object3D.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"Object3D.js","sourceRoot":"","sources":["../../../../engine-components/js-extensions/Object3D.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjC,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,aAAa,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAExO,wFAAwF;AACxF,MAAM,UAAU,KAAK,CAAC,MAAgB;IAClC,IAAI,MAAM,IAAI,MAAM,CAAC,UAAU,KAAK,IAAI,EAAE;QACtC,wBAAwB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;KAC9C;AACL,CAAC;AAID,yBAAyB;AACzB,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,UAAU,MAAe;IACvD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;AAC1B,CAAC,CAAA;AAED,QAAQ,CAAC,SAAS,CAAC,iBAAiB,CAAC,GAAG,UAA+B,IAA4B;IAC/F,OAAO,uBAAuB,CAAC,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;AACrD,CAAC,CAAA;AAED,QAAQ,CAAC,SAAS,CAAC,iBAAiB,CAAC,GAAG,UAAU,IAAe;IAC7D,OAAO,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC,CAAA;AAED,QAAQ,CAAC,SAAS,CAAC,mBAAmB,CAAC,GAAG,UAAgC,QAAgC;IACtG,OAAO,iBAAiB,CAAI,IAAI,EAAE,QAAQ,CAAC,CAAC;AAChD,CAAC,CAAA;AAED,QAAQ,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,UAAgC,IAAoB;IACrF,OAAO,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACpC,CAAC,CAAA;AAED,QAAQ,CAAC,SAAS,CAAC,eAAe,CAAC,GAAG,UAAgC,IAAoB,EAAE,GAAQ;IAChG,OAAO,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;AAC1C,CAAC,CAAA;AAED,QAAQ,CAAC,SAAS,CAAC,wBAAwB,CAAC,GAAG,UAAgC,IAAoB;IAC/F,OAAO,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC9C,CAAC,CAAA;AAED,QAAQ,CAAC,SAAS,CAAC,yBAAyB,CAAC,GAAG,UAAgC,IAAoB,EAAE,GAAQ;IAC1G,OAAO,uBAAuB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;AACpD,CAAC,CAAA;AAED,QAAQ,CAAC,SAAS,CAAC,sBAAsB,CAAC,GAAG,UAAgC,IAAoB;IAC7F,OAAO,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC,CAAA;AAED,QAAQ,CAAC,SAAS,CAAC,uBAAuB,CAAC,GAAG,UAAa,IAAoB,EAAE,GAAQ;IACrF,OAAO,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;AAClD,CAAC,CAAA;AAED,kFAAkF;AAClF,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE;IACpE,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,SAAS,EAAE,YAAY,EAAE;QACpD,GAAG,EAAE;YACD,OAAO,IAAI,CAAC,OAAO,CAAC;QACxB,CAAC;QACD,GAAG,EAAE,UAAU,GAAqB;YAChC,MAAM,KAAK,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;YACxD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACzB,CAAC;KACJ,CAAC,CAAC;CACN;AAKD,gDAAgD;AAChD,2BAA2B,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
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
|
export function apply(object) {
|
|
5
5
|
if (object && object.isVector3 === true) {
|
|
6
|
-
|
|
7
|
-
applyPrototypeExtensions(object);
|
|
6
|
+
applyPrototypeExtensions(object, Vector3);
|
|
8
7
|
}
|
|
9
8
|
}
|
|
10
9
|
Vector3.prototype["slerp"] = function (end, t) {
|
|
@@ -13,4 +12,5 @@ Vector3.prototype["slerp"] = function (end, t) {
|
|
|
13
12
|
const targetLen = Mathf.lerp(len1, len2, t);
|
|
14
13
|
return this.lerp(end, t).normalize().multiplyScalar(targetLen);
|
|
15
14
|
};
|
|
15
|
+
registerPrototypeExtensions(Vector3);
|
|
16
16
|
//# sourceMappingURL=Vector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Vector.js","sourceRoot":"","sources":["../../../../engine-components/js-extensions/Vector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"Vector.js","sourceRoot":"","sources":["../../../../engine-components/js-extensions/Vector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,MAAM,UAAU,KAAK,CAAC,MAAe;IACjC,IAAI,MAAM,IAAI,MAAM,CAAC,SAAS,KAAK,IAAI,EAAE;QACrC,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC7C;AACL,CAAC;AAGD,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,UAAU,GAAY,EAAE,CAAS;IAC1D,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC3B,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;IAC1B,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;AACnE,CAAC,CAAA;AAED,2BAA2B,CAAC,OAAO,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/engine",
|
|
3
|
-
"version": "2.35.
|
|
3
|
+
"version": "2.35.3-pre",
|
|
4
4
|
"description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development, and can be deployed anywhere. It is flexible, extensible, and collaboration and XR come naturally.",
|
|
5
5
|
"main": "dist/needle-engine.js",
|
|
6
6
|
"module": "lib/needle-engine.js",
|
|
@@ -63,6 +63,15 @@
|
|
|
63
63
|
],
|
|
64
64
|
"extensions": "ts",
|
|
65
65
|
"quiet": false
|
|
66
|
+
},
|
|
67
|
+
"build:dist": {
|
|
68
|
+
"patterns": [
|
|
69
|
+
"engine/*",
|
|
70
|
+
"engine-components/*",
|
|
71
|
+
"engine-experimental/**/*"
|
|
72
|
+
],
|
|
73
|
+
"extensions": "ts",
|
|
74
|
+
"quiet": false
|
|
66
75
|
}
|
|
67
76
|
},
|
|
68
77
|
"publishConfig": {
|
|
@@ -4,6 +4,7 @@ import { Context, registerComponent } from "./engine_setup";
|
|
|
4
4
|
import { getParam } from "./engine_utils";
|
|
5
5
|
import { removeScriptFromContext, updateActiveInHierarchyWithoutEventCall } from "./engine_mainloop_utils";
|
|
6
6
|
import { activeInHierarchyFieldName } from "./engine_constants";
|
|
7
|
+
import { apply } from "../engine-components/js-extensions/Object3D";
|
|
7
8
|
|
|
8
9
|
const debug = getParam("debuggetcomponent");
|
|
9
10
|
|
|
@@ -35,10 +36,14 @@ export function getOrAddComponent<T extends IComponent>(go: Object3D, typeName:
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
export function addNewComponentInstance<T extends IComponent>(obj: Object3D, componentInstance: T, callAwake = true): IComponent {
|
|
39
|
+
if (!obj) {
|
|
40
|
+
new Error("Can not add componet to null object");
|
|
41
|
+
}
|
|
38
42
|
if (!obj.userData) obj.userData = {};
|
|
39
43
|
if (!obj.userData.components) obj.userData.components = [];
|
|
40
44
|
obj.userData.components.push(componentInstance);
|
|
41
45
|
componentInstance.gameObject = obj as IGameObject;
|
|
46
|
+
apply(obj);
|
|
42
47
|
// componentInstance.transform = obj;
|
|
43
48
|
registerComponent(componentInstance);
|
|
44
49
|
try {
|
|
@@ -5,7 +5,12 @@ import { processNewScripts } from "./engine_mainloop_utils";
|
|
|
5
5
|
import { calculateProgress01, EngineLoadingView, ILoadingViewHandler } from "./engine_element_loading";
|
|
6
6
|
import { delay, getParam } from "./engine_utils";
|
|
7
7
|
import { setDracoDecoderPath, setDracoDecoderType, setKtx2TranscoderPath } from "./engine_loaders";
|
|
8
|
-
import { getLoader } from "../engine/engine_gltf";
|
|
8
|
+
import { getLoader, registerLoader } from "../engine/engine_gltf";
|
|
9
|
+
import { NeedleGltfLoader } from "./engine_scenetools";
|
|
10
|
+
import { INeedleEngineComponent } from "./engine_types";
|
|
11
|
+
|
|
12
|
+
// registering loader here too to make sure it's imported when using engine via vanilla js
|
|
13
|
+
registerLoader(NeedleGltfLoader);
|
|
9
14
|
|
|
10
15
|
const debug = getParam("debugwebcomponent");
|
|
11
16
|
|
|
@@ -69,7 +74,7 @@ const desktopContainerClassname = "desktop";
|
|
|
69
74
|
const knownClasses = [arContainerClassName, vrContainerClassName, desktopContainerClassname];
|
|
70
75
|
|
|
71
76
|
// https://developers.google.com/web/fundamentals/web-components/customelements
|
|
72
|
-
export class EngineElement extends HTMLElement {
|
|
77
|
+
export class EngineElement extends HTMLElement implements INeedleEngineComponent {
|
|
73
78
|
|
|
74
79
|
public get loadingProgress01(): number { return this._loadingProgress01; }
|
|
75
80
|
public get loadingFinished(): boolean { return this.loadingProgress01 > .999; }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SourceIdentifier, UIDProvider } from "./engine_types";
|
|
1
|
+
import { Constructor, ConstructorConcrete, SourceIdentifier, UIDProvider } from "./engine_types";
|
|
2
2
|
import { Context } from "./engine_setup";
|
|
3
3
|
import { NEEDLE_components } from "./extensions/NEEDLE_components";
|
|
4
4
|
import { SerializationContext } from "./engine_serialization_core";
|
|
@@ -6,18 +6,22 @@ import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js'
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
export interface INeedleGltfLoader {
|
|
9
|
-
createBuiltinComponents(context: Context, gltfId
|
|
9
|
+
createBuiltinComponents(context: Context, gltfId: SourceIdentifier, gltf, seed: number | null | UIDProvider, extension?: NEEDLE_components): Promise<void>
|
|
10
10
|
writeBuiltinComponentData(comp: object, context: SerializationContext);
|
|
11
11
|
parseSync(context: Context, data, path: string, seed: number | UIDProvider | null): Promise<GLTF | undefined>;
|
|
12
12
|
loadSync(context: Context, url: string, seed: number | UIDProvider | null, _allowAddingAnimator: boolean, prog?: (ProgressEvent) => void): Promise<GLTF | undefined>
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
let gltfLoader: INeedleGltfLoader;
|
|
16
|
+
let gltfLoaderType: ConstructorConcrete<INeedleGltfLoader> | null = null;
|
|
16
17
|
|
|
17
18
|
export function getLoader(): INeedleGltfLoader {
|
|
18
19
|
return gltfLoader;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
export function registerLoader(loader
|
|
22
|
-
|
|
22
|
+
export function registerLoader<T extends INeedleGltfLoader>(loader: ConstructorConcrete<T>) {
|
|
23
|
+
if (gltfLoaderType !== loader) {
|
|
24
|
+
gltfLoaderType = loader;
|
|
25
|
+
gltfLoader = new loader();
|
|
26
|
+
}
|
|
23
27
|
}
|
|
@@ -14,7 +14,7 @@ import { NEEDLE_components } from "./extensions/NEEDLE_components";
|
|
|
14
14
|
import { addNewComponentInstance, getComponentInChildren } from "./engine_components";
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
class NeedleGltfLoader implements INeedleGltfLoader {
|
|
17
|
+
export class NeedleGltfLoader implements INeedleGltfLoader {
|
|
18
18
|
createBuiltinComponents(context: Context, gltfId: string, gltf: any, seed: number | UIDProvider | null, extension?: NEEDLE_components | undefined) {
|
|
19
19
|
return createBuiltinComponents(context, gltfId, gltf, seed, extension);
|
|
20
20
|
}
|
|
@@ -31,7 +31,7 @@ class NeedleGltfLoader implements INeedleGltfLoader {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
registerLoader(
|
|
34
|
+
registerLoader(NeedleGltfLoader);
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
const printGltf = utils.getParam("printGltf");
|
|
@@ -18,7 +18,11 @@ export interface UIDProvider {
|
|
|
18
18
|
generateUUID(): string;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
export declare interface INeedleEngineComponent extends HTMLElement {
|
|
22
|
+
getAROverlayContainer(): HTMLElement;
|
|
23
|
+
onEnterAR(session: THREE.XRSession, overlayContainer: HTMLElement);
|
|
24
|
+
onExitAR(session: THREE.XRSession);
|
|
25
|
+
}
|
|
22
26
|
|
|
23
27
|
export declare interface IGameObject extends Object3D {
|
|
24
28
|
guid: string | undefined;
|
|
@@ -36,7 +40,7 @@ export interface IComponent {
|
|
|
36
40
|
get name(): string;
|
|
37
41
|
get layer(): number;
|
|
38
42
|
get destroyed(): boolean;
|
|
39
|
-
|
|
43
|
+
|
|
40
44
|
context: any;
|
|
41
45
|
|
|
42
46
|
get activeAndEnabled(): boolean;
|
|
@@ -75,7 +79,7 @@ export interface IComponent {
|
|
|
75
79
|
__internalHandleCollision(col: Collision, isTriggerCollision: boolean);
|
|
76
80
|
__internalHandleExitCollisionEvent(obj: Object3D, isTriggerCollision: boolean);
|
|
77
81
|
|
|
78
|
-
get forward()
|
|
82
|
+
get forward(): Vector3;
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
|
|
@@ -127,7 +131,7 @@ export declare type CannonCollision = {
|
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
export declare type ICollisionContext = {
|
|
130
|
-
getCollider(obj
|
|
134
|
+
getCollider(obj: Object3D): ICollider;
|
|
131
135
|
}
|
|
132
136
|
|
|
133
137
|
export class Collision {
|
|
@@ -143,7 +147,7 @@ export class Collision {
|
|
|
143
147
|
private readonly invert: boolean;
|
|
144
148
|
private readonly collision: CannonCollision;
|
|
145
149
|
private readonly targetBody: Body;
|
|
146
|
-
private readonly context
|
|
150
|
+
private readonly context: ICollisionContext;
|
|
147
151
|
|
|
148
152
|
readonly me: Object3D;
|
|
149
153
|
|
|
@@ -178,7 +182,7 @@ export class Collision {
|
|
|
178
182
|
// return this._point;
|
|
179
183
|
// }
|
|
180
184
|
|
|
181
|
-
constructor(obj: Object3D, collision: CannonCollision, context
|
|
185
|
+
constructor(obj: Object3D, collision: CannonCollision, context: ICollisionContext, invert: boolean = false) {
|
|
182
186
|
this.me = obj;
|
|
183
187
|
this.collision = collision;
|
|
184
188
|
this.context = context;
|
|
@@ -7,7 +7,7 @@ import { getParam, getPath } from "../engine_utils";
|
|
|
7
7
|
|
|
8
8
|
export const EXTENSION_NAME = "NEEDLE_deferred_texture";
|
|
9
9
|
|
|
10
|
-
const debug = getParam("
|
|
10
|
+
const debug = getParam("debugprogressive");
|
|
11
11
|
|
|
12
12
|
declare type DeferredTextureModel = {
|
|
13
13
|
uri: string;
|
|
@@ -15,9 +15,30 @@ declare type DeferredTextureModel = {
|
|
|
15
15
|
usage?: string,
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
const debug_toggle_maps: Map<Material, { [key: string]: { original: Texture, lod0: Texture } }> = new Map();
|
|
19
|
+
let show_lod0 = false;
|
|
20
|
+
if (debug) {
|
|
21
|
+
window.addEventListener("keyup", evt => {
|
|
22
|
+
if (evt.key === "p") {
|
|
23
|
+
debug_toggle_maps.forEach((map, material) => {
|
|
24
|
+
Object.entries(map).forEach(([key, value]) => {
|
|
25
|
+
if (show_lod0) {
|
|
26
|
+
material[key] = value.lod0;
|
|
27
|
+
} else {
|
|
28
|
+
material[key] = value.original;
|
|
29
|
+
}
|
|
30
|
+
material.needsUpdate = true;
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
show_lod0 = !show_lod0;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
18
38
|
export class NEEDLE_deferred_texture implements GLTFLoaderPlugin {
|
|
19
39
|
|
|
20
|
-
|
|
40
|
+
|
|
41
|
+
static assignTextureLOD(context: Context, source: SourceIdentifier | undefined, material: Material, level: number = 0) {
|
|
21
42
|
if (!material) return;
|
|
22
43
|
for (const slot of Object.keys(material)) {
|
|
23
44
|
const val = material[slot];
|
|
@@ -32,6 +53,18 @@ export class NEEDLE_deferred_texture implements GLTFLoaderPlugin {
|
|
|
32
53
|
material[slot] = t;
|
|
33
54
|
material.needsUpdate = true;
|
|
34
55
|
|
|
56
|
+
if (debug) {
|
|
57
|
+
let debug_map = debug_toggle_maps.get(material);
|
|
58
|
+
if (!debug_map) {
|
|
59
|
+
debug_map = {};
|
|
60
|
+
debug_toggle_maps.set(material, debug_map);
|
|
61
|
+
}
|
|
62
|
+
let entry = debug_map[slot];
|
|
63
|
+
if (!entry) {
|
|
64
|
+
entry = debug_map[slot] = { original: val, lod0: t };
|
|
65
|
+
}
|
|
66
|
+
entry.lod0 = t;
|
|
67
|
+
}
|
|
35
68
|
}
|
|
36
69
|
});
|
|
37
70
|
}
|
|
@@ -93,7 +126,7 @@ export class NEEDLE_deferred_texture implements GLTFLoaderPlugin {
|
|
|
93
126
|
private static cache = new Map<string, DeferredTextureModel>();
|
|
94
127
|
private static resolved: { [key: string]: Texture } = {};
|
|
95
128
|
|
|
96
|
-
private static async getOrLoadTexture(context: Context, source
|
|
129
|
+
private static async getOrLoadTexture(context: Context, source: SourceIdentifier | undefined, material: Material, slot: string, current: Texture, _level: number): Promise<Texture | null> {
|
|
97
130
|
|
|
98
131
|
const key = current.uuid;
|
|
99
132
|
const ext: DeferredTextureModel | undefined = NEEDLE_deferred_texture.cache.get(key);// || current.userData.deferred;
|
|
@@ -113,6 +113,7 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
|
|
|
113
113
|
|
|
114
114
|
public static invoke(go: THREE.Object3D | null | undefined, functionName: string, children: boolean = false, ...args: any) {
|
|
115
115
|
if (!go) return;
|
|
116
|
+
|
|
116
117
|
// console.log(go);
|
|
117
118
|
this.foreachComponent(go, c => {
|
|
118
119
|
const fn = c[functionName];
|
|
@@ -381,6 +382,7 @@ class Component implements IComponent, EventTarget {
|
|
|
381
382
|
if (this.__didEnable) return false;
|
|
382
383
|
// console.trace("INTERNAL ENABLE");
|
|
383
384
|
this.__didEnable = true;
|
|
385
|
+
this.__isEnabled = true;
|
|
384
386
|
this.onEnable();
|
|
385
387
|
return true;
|
|
386
388
|
}
|
|
@@ -389,6 +391,7 @@ class Component implements IComponent, EventTarget {
|
|
|
389
391
|
if (!this.__didEnable) return;
|
|
390
392
|
this.__didEnable = false;
|
|
391
393
|
this._collisionExitRoutine = undefined;
|
|
394
|
+
this.__isEnabled = false;
|
|
392
395
|
this.onDisable();
|
|
393
396
|
this._collisions?.clear();
|
|
394
397
|
}
|
|
@@ -415,7 +418,10 @@ class Component implements IComponent, EventTarget {
|
|
|
415
418
|
}
|
|
416
419
|
|
|
417
420
|
// need to check here because codegen is calling this before everything is setup
|
|
418
|
-
if (!this.__didAwake)
|
|
421
|
+
if (!this.__didAwake) {
|
|
422
|
+
this.__isEnabled = val;
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
419
425
|
if (val) {
|
|
420
426
|
this.__internalEnable();
|
|
421
427
|
} else {
|
|
@@ -13,6 +13,7 @@ import { getWorldPosition, getWorldQuaternion, setWorldPosition } from "../engin
|
|
|
13
13
|
import { KeyCode } from "../engine/engine_input";
|
|
14
14
|
import { nameofFactory } from "../engine/engine_utils";
|
|
15
15
|
import { InstancingUtil } from "../engine/engine_instancing";
|
|
16
|
+
import { OrbitControls } from "./OrbitControls";
|
|
16
17
|
|
|
17
18
|
const debug = false;
|
|
18
19
|
|
|
@@ -43,7 +44,7 @@ export class DragControls extends Interactable implements IPointerDownHandler, I
|
|
|
43
44
|
// public targets: THREE.Object3D[] | null = null;
|
|
44
45
|
|
|
45
46
|
// private controls: Control | null = null;
|
|
46
|
-
|
|
47
|
+
private orbit: OrbitControls | null = null;
|
|
47
48
|
|
|
48
49
|
private selectStartEventListener: ((controls: DragControls, args: SelectArgs) => void)[] = [];
|
|
49
50
|
private selectEndEventListener: Array<Function> = [];
|
|
@@ -70,7 +71,7 @@ export class DragControls extends Interactable implements IPointerDownHandler, I
|
|
|
70
71
|
|
|
71
72
|
|
|
72
73
|
start() {
|
|
73
|
-
|
|
74
|
+
this.orbit = GameObject.findObjectOfType(OrbitControls, this.context);
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
private static lastHovered: THREE.Object3D;
|
|
@@ -148,8 +149,11 @@ export class DragControls extends Interactable implements IPointerDownHandler, I
|
|
|
148
149
|
this.onUpdateDrag();
|
|
149
150
|
}
|
|
150
151
|
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
|
|
153
|
+
if (this._isDragging) {
|
|
154
|
+
if (this._dragHelper?.hasSelected === false) {
|
|
155
|
+
this.onDragEnd(null);
|
|
156
|
+
}
|
|
153
157
|
}
|
|
154
158
|
}
|
|
155
159
|
|
|
@@ -197,7 +201,7 @@ export class DragControls extends Interactable implements IPointerDownHandler, I
|
|
|
197
201
|
object = args.attached;
|
|
198
202
|
this._isDragging = true;
|
|
199
203
|
this._dragHelper.setSelected(object, this.context);
|
|
200
|
-
|
|
204
|
+
if (this.orbit) this.orbit.enabled = false;
|
|
201
205
|
|
|
202
206
|
const sync = GameObject.getComponentInChildren(object, SyncedTransform);
|
|
203
207
|
if (debug)
|
|
@@ -239,7 +243,7 @@ export class DragControls extends Interactable implements IPointerDownHandler, I
|
|
|
239
243
|
if (debug)
|
|
240
244
|
console.log("DRAG END", selected, selected?.visible)
|
|
241
245
|
this._dragHelper.setSelected(null, this.context);
|
|
242
|
-
|
|
246
|
+
if (this.orbit) this.orbit.enabled = true;
|
|
243
247
|
if (evt?.object) {
|
|
244
248
|
const sync = GameObject.getComponentInChildren(evt.object, SyncedTransform);
|
|
245
249
|
if (sync) {
|
|
@@ -316,7 +320,6 @@ class DragHelper {
|
|
|
316
320
|
}
|
|
317
321
|
|
|
318
322
|
setSelected(newSelected: THREE.Object3D | null, context: Context) {
|
|
319
|
-
|
|
320
323
|
if (this._selected && context) {
|
|
321
324
|
for (const rb of this._rbs) {
|
|
322
325
|
rb.wakeUp();
|
|
@@ -343,7 +346,6 @@ class DragHelper {
|
|
|
343
346
|
this._groundMarker.removeFromParent();
|
|
344
347
|
}
|
|
345
348
|
|
|
346
|
-
|
|
347
349
|
if (this._selected) {
|
|
348
350
|
if (!context) {
|
|
349
351
|
console.error("DragHelper: no context");
|
|
@@ -17,8 +17,8 @@ export { InstancingUtil } from "../engine/engine_instancing";
|
|
|
17
17
|
const suppressInstancing = getParam("noInstancing");
|
|
18
18
|
const debugLightmap = getParam("debuglightmaps") ? true : false;
|
|
19
19
|
const debugInstancing = getParam("debuginstancing");
|
|
20
|
-
const debugProgressiveLoading = getParam("
|
|
21
|
-
const suppressProgressiveLoading = getParam("
|
|
20
|
+
const debugProgressiveLoading = getParam("debugprogressive");
|
|
21
|
+
const suppressProgressiveLoading = getParam("noprogressive");
|
|
22
22
|
|
|
23
23
|
export class FieldWithDefault {
|
|
24
24
|
public path: string | null = null;
|
|
@@ -31,6 +31,12 @@ function disposeStream(str: MediaStream | null | undefined) {
|
|
|
31
31
|
cap.stop();
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
declare type ScreenCaptureOptions = {
|
|
35
|
+
device?: ScreenCaptureDevice,
|
|
36
|
+
deviceId?: string,
|
|
37
|
+
constraints?: MediaTrackConstraints,
|
|
38
|
+
}
|
|
39
|
+
|
|
34
40
|
export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
35
41
|
|
|
36
42
|
onPointerClick() {
|
|
@@ -82,7 +88,8 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
82
88
|
private _currentMode: ScreenCaptureMode = ScreenCaptureMode.Idle;
|
|
83
89
|
|
|
84
90
|
awake() {
|
|
85
|
-
|
|
91
|
+
if (debug)
|
|
92
|
+
console.log(this);
|
|
86
93
|
AudioSource.registerWaitForAllowAudio(() => {
|
|
87
94
|
if (this.videoPlayer && this._currentStream && this._currentMode === ScreenCaptureMode.Receiving) {
|
|
88
95
|
this.videoPlayer.setVideo(this._currentStream);
|
|
@@ -105,12 +112,16 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
105
112
|
this._net.addEventListener(PeerEvent.ReceiveVideo, this.onReceiveVideo.bind(this));
|
|
106
113
|
}
|
|
107
114
|
|
|
108
|
-
async share() {
|
|
115
|
+
async share(opts?: ScreenCaptureOptions) {
|
|
116
|
+
|
|
117
|
+
if (opts?.device)
|
|
118
|
+
this.device = opts.device;
|
|
119
|
+
|
|
109
120
|
this._requestOpen = true;
|
|
110
121
|
try {
|
|
111
122
|
if (this.videoPlayer) {
|
|
112
123
|
|
|
113
|
-
const settings: MediaTrackConstraints = {
|
|
124
|
+
const settings: MediaTrackConstraints = opts?.constraints ?? {
|
|
114
125
|
echoCancellation: true,
|
|
115
126
|
autoGainControl: false,
|
|
116
127
|
};
|
|
@@ -122,7 +133,7 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
122
133
|
switch (this.device) {
|
|
123
134
|
// Capture a connected camera
|
|
124
135
|
case ScreenCaptureDevice.Camera:
|
|
125
|
-
this.tryShareUserCamera(displayMediaOptions);
|
|
136
|
+
this.tryShareUserCamera(displayMediaOptions, opts);
|
|
126
137
|
break;
|
|
127
138
|
|
|
128
139
|
// capture any screen, will show a popup
|
|
@@ -197,7 +208,7 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
197
208
|
|
|
198
209
|
|
|
199
210
|
|
|
200
|
-
private async tryShareUserCamera(opts: DisplayMediaStreamConstraints) {
|
|
211
|
+
private async tryShareUserCamera(opts: DisplayMediaStreamConstraints, options?: ScreenCaptureOptions) {
|
|
201
212
|
|
|
202
213
|
// let newWindow = open('', 'example', 'width=300,height=300');
|
|
203
214
|
// if (window) {
|
|
@@ -212,6 +223,10 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
212
223
|
if (!this._requestOpen) break;
|
|
213
224
|
if (dev.kind !== "videoinput") continue;
|
|
214
225
|
const id = dev.deviceId;
|
|
226
|
+
if (options?.deviceId !== undefined) {
|
|
227
|
+
if (id !== options.deviceId)
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
215
230
|
if (opts.video !== false) {
|
|
216
231
|
if (typeof opts.video === "undefined" || typeof opts.video === "boolean") {
|
|
217
232
|
opts.video = {};
|
|
@@ -13,11 +13,11 @@ import { ControllerType, WebXRController } from "./WebXRController";
|
|
|
13
13
|
import { WebARSessionRoot } from "./WebARSessionRoot";
|
|
14
14
|
import { getWorldPosition, getWorldQuaternion, setWorldPosition, setWorldQuaternion } from "../engine/engine_three_utils";
|
|
15
15
|
import { XRRig } from "./WebXRRig";
|
|
16
|
-
import { EngineElement } from "../engine/engine_element";
|
|
17
16
|
import { AssetReference } from "../engine/engine_addressables";
|
|
18
17
|
import { serializeable } from "../engine/engine_serialization_decorator";
|
|
19
18
|
import { WebXRSync } from "./WebXRSync";
|
|
20
19
|
import { XRSessionMode } from "../engine/engine_setup";
|
|
20
|
+
import { INeedleEngineComponent } from "../engine/engine_types";
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
export async function detectARSupport() {
|
|
@@ -210,7 +210,7 @@ export class WebXR extends Behaviour {
|
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
// VR support
|
|
213
|
-
if (this.createVRButton && this.enableVR
|
|
213
|
+
if (this.createVRButton && this.enableVR) {
|
|
214
214
|
vrButton = WebXR.createVRButton(this);
|
|
215
215
|
this._vrButton = vrButton;
|
|
216
216
|
buttonsContainer.appendChild(vrButton);
|
|
@@ -477,16 +477,17 @@ export class WebAR {
|
|
|
477
477
|
this._webxr = webxr;
|
|
478
478
|
}
|
|
479
479
|
|
|
480
|
-
private arDomOverlay:
|
|
481
|
-
private arOverlayElement: HTMLElement | null = null;
|
|
480
|
+
private arDomOverlay: HTMLElement | null = null;
|
|
481
|
+
private arOverlayElement: INeedleEngineComponent | HTMLElement | null = null;
|
|
482
482
|
private noHitTestAvailable: boolean = false;
|
|
483
483
|
private didPlaceARSessionRoot: boolean = false;
|
|
484
484
|
|
|
485
485
|
getAROverlayContainer(): HTMLElement | null {
|
|
486
|
-
this.arDomOverlay = this.webxr.context.domElement as
|
|
486
|
+
this.arDomOverlay = this.webxr.context.domElement as HTMLElement;
|
|
487
487
|
// for react cases we dont have an Engine Element
|
|
488
|
-
|
|
489
|
-
|
|
488
|
+
const element : any = this.arDomOverlay;
|
|
489
|
+
if (element.getAROverlayContainer)
|
|
490
|
+
this.arOverlayElement = element.getAROverlayContainer();
|
|
490
491
|
else this.arOverlayElement = this.arDomOverlay;
|
|
491
492
|
return this.arOverlayElement;
|
|
492
493
|
}
|
|
@@ -548,13 +549,14 @@ export class WebAR {
|
|
|
548
549
|
else console.warn("No WebARSessionRoot found in scene")
|
|
549
550
|
|
|
550
551
|
if (this.arDomOverlay && this.arOverlayElement) {
|
|
551
|
-
|
|
552
|
+
const el = this.arOverlayElement as INeedleEngineComponent;
|
|
553
|
+
el.onEnterAR?.call(el, session, this.arOverlayElement);
|
|
552
554
|
}
|
|
553
555
|
|
|
554
556
|
this.context.mainCameraComponent?.applyClearFlagsIfIsActiveCamera();
|
|
555
557
|
}
|
|
556
558
|
|
|
557
|
-
onEnd(
|
|
559
|
+
onEnd(session: THREE.XRSession) {
|
|
558
560
|
if (this._previousParent) {
|
|
559
561
|
console.log("ADD", this._previousParent);
|
|
560
562
|
GameObject.addComponent(this._previousParent as GameObject, this.webxr);
|
|
@@ -565,9 +567,13 @@ export class WebAR {
|
|
|
565
567
|
context.scene.background = this.previousBackground;
|
|
566
568
|
context.scene.environment = this.previousEnvironment;
|
|
567
569
|
if (this.sessionRoot) {
|
|
568
|
-
this.sessionRoot.onEnd(this.webxr.Rig,
|
|
570
|
+
this.sessionRoot.onEnd(this.webxr.Rig, session);
|
|
571
|
+
}
|
|
572
|
+
if (this.arDomOverlay)
|
|
573
|
+
{
|
|
574
|
+
const el = this.arOverlayElement as INeedleEngineComponent;
|
|
575
|
+
el.onExitAR?.call(el, session);
|
|
569
576
|
}
|
|
570
|
-
if (this.arDomOverlay) this.arDomOverlay.onExitAR(_session);
|
|
571
577
|
|
|
572
578
|
this.context.mainCameraComponent?.applyClearFlagsIfIsActiveCamera();
|
|
573
579
|
}
|