@needle-tools/engine 2.53.0-pre → 2.54.2-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 +27 -0
- package/dist/needle-engine.d.ts +2417 -2230
- package/dist/needle-engine.js +425 -425
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +49 -49
- package/dist/needle-engine.min.js.map +4 -4
- package/dist/needle-engine.tsbuildinfo +1 -0
- package/lib/engine/codegen/register_types.d.ts +1 -0
- package/lib/engine/codegen/register_types.js +346 -0
- package/lib/engine/codegen/register_types.js.map +1 -0
- package/lib/engine/debug/debug.d.ts +1 -0
- package/lib/engine/debug/debug.js +4 -0
- package/lib/engine/debug/debug.js.map +1 -1
- package/lib/engine/debug/debug_console.js +2 -1
- package/lib/engine/debug/debug_console.js.map +1 -1
- package/lib/engine/debug/debug_overlay.js +3 -1
- package/lib/engine/debug/debug_overlay.js.map +1 -1
- package/lib/engine/engine_default_parameters.d.ts +2 -2
- package/lib/engine/engine_element.js +4 -2
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_element_loading.d.ts +1 -0
- package/lib/engine/engine_element_loading.js +17 -6
- package/lib/engine/engine_element_loading.js.map +1 -1
- package/lib/engine/engine_element_overlay.js +4 -2
- package/lib/engine/engine_element_overlay.js.map +1 -1
- package/lib/engine/engine_fileloader.d.ts +3 -0
- package/lib/engine/engine_fileloader.js +8 -0
- package/lib/engine/engine_fileloader.js.map +1 -0
- package/lib/engine/engine_generic_utils.d.ts +1 -0
- package/lib/engine/engine_generic_utils.js +14 -0
- package/lib/engine/engine_generic_utils.js.map +1 -0
- package/lib/engine/engine_input.js +4 -0
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_networking_websocket.d.ts +1 -0
- package/lib/engine/engine_networking_websocket.js +1 -1
- package/lib/engine/engine_networking_websocket.js.map +1 -1
- package/lib/engine/engine_serialization_builtin_serializer.js +6 -3
- package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
- package/lib/engine/engine_utils.d.ts +1 -1
- package/lib/engine/engine_utils.js +3 -0
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_components.d.ts +1 -1
- package/lib/engine/extensions/NEEDLE_progressive.d.ts +22 -0
- package/lib/engine/extensions/NEEDLE_progressive.js +172 -44
- package/lib/engine/extensions/NEEDLE_progressive.js.map +1 -1
- package/lib/engine-components/GroundProjection.d.ts +2 -1
- package/lib/engine-components/GroundProjection.js +19 -12
- package/lib/engine-components/GroundProjection.js.map +1 -1
- package/lib/engine-components/ParticleSystemModules.d.ts +1 -1
- package/lib/engine-components/ParticleSystemModules.js +48 -44
- package/lib/engine-components/ParticleSystemModules.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +1 -1
- package/lib/engine-components/Renderer.d.ts +1 -1
- package/lib/engine-components/Renderer.js +3 -8
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/Volume.js +8 -1
- package/lib/engine-components/Volume.js.map +1 -1
- package/lib/engine-components/WebXR.d.ts +2 -2
- package/lib/engine-components/WebXRAvatar.d.ts +1 -1
- package/lib/engine-components/codegen/components.d.ts +99 -99
- package/lib/engine-components/codegen/components.js +99 -99
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.d.ts +1 -0
- package/lib/engine-components/export/usdz/USDZExporter.js +17 -1
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/ui/Button.js +30 -0
- package/lib/engine-components/ui/Button.js.map +1 -1
- package/lib/engine-components/ui/InputField.d.ts +2 -0
- package/lib/engine-components/ui/InputField.js +23 -1
- package/lib/engine-components/ui/InputField.js.map +1 -1
- package/lib/engine-components/ui/Utils.d.ts +2 -0
- package/lib/engine-components/ui/Utils.js +10 -9
- package/lib/engine-components/ui/Utils.js.map +1 -1
- package/lib/engine-components-experimental/Presentation.d.ts +6 -0
- package/lib/engine-components-experimental/Presentation.js +11 -0
- package/lib/engine-components-experimental/Presentation.js.map +1 -0
- package/lib/engine-components-experimental/annotation/LineDrawer.d.ts +18 -0
- package/lib/engine-components-experimental/annotation/LineDrawer.js +175 -0
- package/lib/engine-components-experimental/annotation/LineDrawer.js.map +1 -0
- package/lib/engine-components-experimental/annotation/LinesManager.d.ts +54 -0
- package/lib/engine-components-experimental/annotation/LinesManager.js +155 -0
- package/lib/engine-components-experimental/annotation/LinesManager.js.map +1 -0
- package/lib/engine-components-experimental/networking/PlayerSync.d.ts +26 -0
- package/lib/engine-components-experimental/networking/PlayerSync.js +121 -0
- package/lib/engine-components-experimental/networking/PlayerSync.js.map +1 -0
- package/lib/engine-schemes/vec2.d.ts +10 -0
- package/lib/engine-schemes/vec2.js +26 -0
- package/lib/engine-schemes/vec2.js.map +1 -0
- package/lib/include/three/ARButton.d.ts +3 -0
- package/lib/include/three/ARButton.js +158 -0
- package/lib/include/three/ARButton.js.map +1 -0
- package/lib/include/three/EXT_mesh_gpu_instancing_exporter.d.ts +6 -0
- package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js +46 -0
- package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js.map +1 -0
- package/lib/include/three/VRButton.d.ts +5 -0
- package/lib/include/three/VRButton.js +122 -0
- package/lib/include/three/VRButton.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
- package/src/engine/codegen/register_types.js +214 -214
- package/src/engine/debug/debug.ts +5 -0
- package/src/engine/debug/debug_console.ts +3 -2
- package/src/engine/debug/debug_overlay.ts +3 -1
- package/src/engine/engine_element.ts +4 -2
- package/src/engine/engine_element_loading.ts +13 -6
- package/src/engine/engine_element_overlay.ts +4 -2
- package/src/engine/engine_input.ts +4 -0
- package/src/engine/engine_networking_websocket.ts +3 -1
- package/src/engine/engine_serialization_builtin_serializer.ts +8 -5
- package/src/engine/engine_utils.ts +3 -1
- package/src/engine/extensions/NEEDLE_progressive.ts +185 -43
- package/src/engine-components/GroundProjection.ts +18 -12
- package/src/engine-components/ParticleSystemModules.ts +50 -47
- package/src/engine-components/Renderer.ts +5 -9
- package/src/engine-components/Volume.ts +8 -1
- package/src/engine-components/WebXR.ts +2 -2
- package/src/engine-components/codegen/components.ts +99 -99
- package/src/engine-components/export/usdz/USDZExporter.ts +19 -2
- package/src/engine-components/ui/Button.ts +8 -8
- package/src/engine-components/ui/InputField.ts +25 -2
- package/src/engine-components/ui/Utils.ts +12 -11
- package/src/engine-components-experimental/annotation/LineDrawer.ts +10 -7
- package/src/engine-components-experimental/annotation/LinesManager.ts +6 -6
- package/src/engine-components-experimental/networking/PlayerSync.ts +1 -1
- package/lib/engine/engine_caching.d.ts +0 -0
- package/lib/engine/engine_caching.js +0 -2
- package/lib/engine/engine_caching.js.map +0 -1
- package/lib/engine/tests/simulate_avatars.d.ts +0 -0
- package/lib/engine/tests/simulate_avatars.js +0 -3
- package/lib/engine/tests/simulate_avatars.js.map +0 -1
- package/lib/engine-components/NavMesh.d.ts +0 -0
- package/lib/engine-components/NavMesh.js +0 -101
- package/lib/engine-components/NavMesh.js.map +0 -1
- package/lib/engine-components/ParticleSystemBehaviours.d.ts +0 -0
- package/lib/engine-components/ParticleSystemBehaviours.js +0 -2
- package/lib/engine-components/ParticleSystemBehaviours.js.map +0 -1
- package/lib/engine-components/SpringJoint.d.ts +0 -0
- package/lib/engine-components/SpringJoint.js +0 -43
- package/lib/engine-components/SpringJoint.js.map +0 -1
- package/lib/engine-components/ui/CanvasScaler.d.ts +0 -0
- package/lib/engine-components/ui/CanvasScaler.js +0 -17
- package/lib/engine-components/ui/CanvasScaler.js.map +0 -1
- package/src/engine/dist/engine_three_utils.js +0 -279
- package/src/engine/engine_caching.ts +0 -0
- package/src/engine/tests/simulate_avatars.ts +0 -2
- package/src/engine-components/NavMesh.ts +0 -117
- package/src/engine-components/ParticleSystemBehaviours.ts +0 -0
- package/src/engine-components/SpringJoint.ts +0 -45
- package/src/engine-components/ui/CanvasScaler.ts +0 -21
|
@@ -120,7 +120,7 @@ export class LinesManager extends Behaviour {
|
|
|
120
120
|
|
|
121
121
|
public endLine(handle: LineHandle, send: boolean = true): LineInstanceHandler | undefined {
|
|
122
122
|
const line = this.inFlight[handle.id];
|
|
123
|
-
if (!line) return;
|
|
123
|
+
if (!line) return undefined;
|
|
124
124
|
this.finished.push(line);
|
|
125
125
|
delete this.inFlight[handle.id];
|
|
126
126
|
|
|
@@ -173,16 +173,16 @@ export class LinesManager extends Behaviour {
|
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
private onEnsureLine(lineId: number, parentGuid: string): LineInstanceHandler {
|
|
176
|
+
private onEnsureLine(lineId: number, parentGuid: string): LineInstanceHandler | null {
|
|
177
177
|
if (this.inFlight[lineId]) return this.inFlight[lineId];
|
|
178
178
|
let obj = GameObject.findByGuid(parentGuid, this.context.scene);
|
|
179
179
|
if (!obj) {
|
|
180
|
-
return;
|
|
180
|
+
return null;
|
|
181
181
|
}
|
|
182
182
|
this.internalStartLine(obj as THREE.Object3D, lineId, false);
|
|
183
183
|
return this.inFlight[lineId];
|
|
184
184
|
}
|
|
185
|
-
private internalStartLine(parent: THREE.Object3D, id: number, send: boolean = true, options?: LineOptions): LineHandle {
|
|
185
|
+
private internalStartLine(parent: THREE.Object3D | null | undefined, id: number, send: boolean = true, options?: LineOptions): LineHandle {
|
|
186
186
|
const line = new LineInstanceHandler(parent ?? this.context.scene, options);
|
|
187
187
|
line.id = id;
|
|
188
188
|
this.inFlight[id] = line;
|
|
@@ -197,14 +197,14 @@ export class LinesManager extends Behaviour {
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
private sendLineStart(instance: LineInstanceHandler) {
|
|
200
|
-
const parent = instance.mesh
|
|
200
|
+
const parent = instance.mesh!.parent;
|
|
201
201
|
this.context.connection.send("line-start", { id: instance.id, parentGuid: parent ? parent["guid"] : undefined })
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
private sendLineUpdate(instance: LineInstanceHandler, finished: boolean, startIndex?: number, points?: Array<any>) {
|
|
205
205
|
if (instance) {
|
|
206
206
|
const model: LineModel = {
|
|
207
|
-
parentGuid: instance.mesh
|
|
207
|
+
parentGuid: instance.mesh!.parent!["guid"],
|
|
208
208
|
guid: instance.id,
|
|
209
209
|
points: points ? [...points] : instance.points,
|
|
210
210
|
width: instance.material!.lineWidth,
|
|
@@ -47,7 +47,7 @@ export class PlayerSync extends Behaviour {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
private watchTabVisible() {
|
|
50
|
-
window.addEventListener("visibilitychange",
|
|
50
|
+
window.addEventListener("visibilitychange", _ => {
|
|
51
51
|
if (document.visibilityState === "visible") {
|
|
52
52
|
for (let i = PlayerState.all.length - 1; i >= 0; i--) {
|
|
53
53
|
const pl = PlayerState.all[i];
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"engine_caching.js","sourceRoot":"","sources":["../../../engine/engine_caching.ts"],"names":[],"mappings":""}
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simulate_avatars.js","sourceRoot":"","sources":["../../../../engine/tests/simulate_avatars.ts"],"names":[],"mappings":";AACA,OAAO"}
|
|
File without changes
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { Behaviour, GameObject } from "./Component";
|
|
3
|
-
// /*
|
|
4
|
-
// import { Pathfinding, PathfindingHelper } from 'three-pathfinding';
|
|
5
|
-
// import * as THREE from 'three';
|
|
6
|
-
// import { mergeBufferGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils'
|
|
7
|
-
// */
|
|
8
|
-
// export class NavMesh extends Behaviour {
|
|
9
|
-
// /*
|
|
10
|
-
// public meshes: THREE.Object3D[] = [];
|
|
11
|
-
// private pathfinding: Pathfinding | null = null;
|
|
12
|
-
// private zones: string[] = [];
|
|
13
|
-
// onEnable(): void {
|
|
14
|
-
// this.pathfinding = new Pathfinding();
|
|
15
|
-
// const ZONE = 'zone';
|
|
16
|
-
// const geometries : THREE.BufferGeometry[] = [];
|
|
17
|
-
// if (this.meshes && this.meshes.length > 0) {
|
|
18
|
-
// for (let i = 0; i < this.meshes.length; i++) {
|
|
19
|
-
// const obj = this.meshes[i] as THREE.Mesh;
|
|
20
|
-
// if (!obj) continue;
|
|
21
|
-
// const geo = obj.geometry;
|
|
22
|
-
// if (!geo) continue;
|
|
23
|
-
// const copy : THREE.BufferGeometry = {...geo};
|
|
24
|
-
// // const copy = geo;
|
|
25
|
-
// const attributesCopy = {...copy.attributes};
|
|
26
|
-
// copy.attributes = attributesCopy;
|
|
27
|
-
// if(attributesCopy.uv2) delete attributesCopy.uv2;
|
|
28
|
-
// // copy.applyMatrix4(obj.matrixWorld);
|
|
29
|
-
// geometries.push(copy);
|
|
30
|
-
// // obj.updateMatrixWorld();
|
|
31
|
-
// // singleGeometry.merge(geo);
|
|
32
|
-
// // console.log(singleGeometry, geo);
|
|
33
|
-
// }
|
|
34
|
-
// }
|
|
35
|
-
// const mesh = mergeBufferGeometries(geometries);
|
|
36
|
-
// const zone = Pathfinding.createZone(mesh);
|
|
37
|
-
// const name = ZONE;
|
|
38
|
-
// this.zones.push(name);
|
|
39
|
-
// this.pathfinding.setZoneData(name, zone);
|
|
40
|
-
// // const target = new THREE.Vector3(2, 0, 2);
|
|
41
|
-
// // const groupID = this.pathfinding.getGroup(ZONE, target);
|
|
42
|
-
// // const path = this.pathfinding.findPath(this.worldPosition, target, ZONE, groupID);
|
|
43
|
-
// // console.log(path, this.pathfinding);
|
|
44
|
-
// }
|
|
45
|
-
// public tryFindPath(from: THREE.Vector3, to: THREE.Vector3): THREE.Vector3[] | null {
|
|
46
|
-
// const zone = this.zones[0];
|
|
47
|
-
// const groupId = this.pathfinding.getGroup(zone, to);
|
|
48
|
-
// const path = this.pathfinding.findPath(from, to, zone, groupId);
|
|
49
|
-
// return path;
|
|
50
|
-
// }
|
|
51
|
-
// */
|
|
52
|
-
// }
|
|
53
|
-
// // import { input } from "../engine/engine_input";
|
|
54
|
-
// import { Physics, RaycastOptions } from "../engine/engine_physics"
|
|
55
|
-
// // import { time } from "../engine/engine_time";
|
|
56
|
-
// // import { scene } from "../engine/engine_setup";
|
|
57
|
-
// import {SyncedTransform} from "./SyncedTransform";
|
|
58
|
-
// export class NavMeshAgent extends Behaviour {
|
|
59
|
-
// /*
|
|
60
|
-
// public navMesh: NavMesh | null = null;
|
|
61
|
-
// private currentPath: THREE.Vector3[] | null = null;
|
|
62
|
-
// private helper : PathfindingHelper | null = null;
|
|
63
|
-
// onEnable(): void {
|
|
64
|
-
// this.helper = new PathfindingHelper();
|
|
65
|
-
// scene.add(this.helper);
|
|
66
|
-
// }
|
|
67
|
-
// update(): void {
|
|
68
|
-
// if (input.mouseClick) {
|
|
69
|
-
// if (this.navMesh) {
|
|
70
|
-
// const from = this.worldPosition;
|
|
71
|
-
// const opts = new RaycastOptions();
|
|
72
|
-
// opts.setMask(RaycastOptions.AllLayers);
|
|
73
|
-
// const hits = Physics.raycast(opts);
|
|
74
|
-
// if (hits.length > 0) {
|
|
75
|
-
// const to = hits[0].point;
|
|
76
|
-
// this.helper.setPlayerPosition(from);
|
|
77
|
-
// this.helper.setTargetPosition(to);
|
|
78
|
-
// this.currentPath = this.navMesh.tryFindPath(from, to);
|
|
79
|
-
// this.helper.setPath(this.currentPath);
|
|
80
|
-
// // console.log(...this.currentPath);
|
|
81
|
-
// const sync = GameObject.getComponent(this.gameObject, SyncedTransform);
|
|
82
|
-
// if(sync) sync.requestOwnership();
|
|
83
|
-
// }
|
|
84
|
-
// }
|
|
85
|
-
// }
|
|
86
|
-
// if (this.currentPath && this.currentPath.length > 0) {
|
|
87
|
-
// const wp = this.worldPosition;
|
|
88
|
-
// const target = this.currentPath[0];
|
|
89
|
-
// this.worldPosition = wp.lerp(target, time.deltaTime*2);
|
|
90
|
-
// this.gameObject.lookAt(target);
|
|
91
|
-
// // const vec = target.clone().sub(wp);
|
|
92
|
-
// // const wr = this.worldQuaternion;
|
|
93
|
-
// // wr.slerp(rot, time.deltaTime*5);
|
|
94
|
-
// // this.worldQuaternion = wr;
|
|
95
|
-
// if (wp.distanceTo(this.currentPath[0]) < 0.1)
|
|
96
|
-
// this.currentPath.shift();
|
|
97
|
-
// }
|
|
98
|
-
// }
|
|
99
|
-
// */
|
|
100
|
-
// }
|
|
101
|
-
//# sourceMappingURL=NavMesh.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NavMesh.js","sourceRoot":"","sources":["../../../engine-components/NavMesh.ts"],"names":[],"mappings":";AACA,uDAAuD;AACvD,KAAK;AACL,sEAAsE;AACtE,kCAAkC;AAClC,uFAAuF;AACvF,KAAK;AACL,2CAA2C;AAC3C,KAAK;AACL,4CAA4C;AAE5C,sDAAsD;AACtD,oCAAoC;AAEpC,yBAAyB;AAEzB,gDAAgD;AAChD,+BAA+B;AAC/B,0DAA0D;AAC1D,uDAAuD;AACvD,6DAA6D;AAC7D,4DAA4D;AAC5D,sCAAsC;AACtC,4CAA4C;AAC5C,sCAAsC;AACtC,gEAAgE;AAChE,uCAAuC;AACvC,+DAA+D;AAC/D,oDAAoD;AACpD,oEAAoE;AACpE,yDAAyD;AACzD,yCAAyC;AACzC,8CAA8C;AAC9C,gDAAgD;AAChD,uDAAuD;AACvD,gBAAgB;AAChB,YAAY;AACZ,0DAA0D;AAC1D,qDAAqD;AACrD,6BAA6B;AAC7B,iCAAiC;AACjC,oDAAoD;AAEpD,wDAAwD;AACxD,sEAAsE;AACtE,gGAAgG;AAChG,kDAAkD;AAClD,QAAQ;AAER,2FAA2F;AAC3F,sCAAsC;AACtC,+DAA+D;AAC/D,2EAA2E;AAC3E,uBAAuB;AACvB,QAAQ;AACR,SAAS;AACT,IAAI;AAEJ,qDAAqD;AACrD,qEAAqE;AACrE,mDAAmD;AACnD,qDAAqD;AACrD,qDAAqD;AAErD,gDAAgD;AAChD,SAAS;AACT,6CAA6C;AAE7C,0DAA0D;AAC1D,wDAAwD;AAExD,yBAAyB;AACzB,iDAAiD;AACjD,kCAAkC;AAClC,QAAQ;AAER,uBAAuB;AACvB,kCAAkC;AAClC,kCAAkC;AAClC,mDAAmD;AACnD,qDAAqD;AACrD,0DAA0D;AAC1D,sDAAsD;AACtD,yCAAyC;AACzC,gDAAgD;AAChD,2DAA2D;AAC3D,yDAAyD;AACzD,6EAA6E;AAC7E,6DAA6D;AAC7D,2DAA2D;AAE3D,8FAA8F;AAC9F,wDAAwD;AACxD,oBAAoB;AACpB,gBAAgB;AAChB,YAAY;AAEZ,iEAAiE;AAEjE,6CAA6C;AAC7C,kDAAkD;AAClD,sEAAsE;AAEtE,8CAA8C;AAC9C,qDAAqD;AACrD,kDAAkD;AAClD,kDAAkD;AAClD,4CAA4C;AAE5C,4DAA4D;AAC5D,4CAA4C;AAG5C,YAAY;AACZ,QAAQ;AACR,SAAS;AACT,IAAI"}
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ParticleSystemBehaviours.js","sourceRoot":"","sources":["../../../engine-components/ParticleSystemBehaviours.ts"],"names":[],"mappings":""}
|
|
File without changes
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { Behaviour, GameObject } from "./Component";
|
|
3
|
-
// import { Rigidbody } from "./RigidBody";
|
|
4
|
-
// import * as CANNON from 'cannon-es'
|
|
5
|
-
// import { Vector3 } from "three";
|
|
6
|
-
// export class SpringJoint extends Behaviour {
|
|
7
|
-
// anchor: Vector3 | null = null;
|
|
8
|
-
// connectedBody: Rigidbody | null = null;
|
|
9
|
-
// connectedAnchor: Vector3 | null = null;
|
|
10
|
-
// spring: number = 10;
|
|
11
|
-
// damper: number = .2;
|
|
12
|
-
// private rb : Rigidbody | null = null;
|
|
13
|
-
// awake(): void {
|
|
14
|
-
// this.rb = GameObject.getComponent(this.gameObject, Rigidbody);
|
|
15
|
-
// if(!this.connectedBody || !this.connectedBody.body || !this.rb || !this.rb.body) return;
|
|
16
|
-
// this.connectedBody.body.mass = Math.min(this.rb.body.mass*.99, this.connectedBody.body.mass);
|
|
17
|
-
// const spring = new CANNON.Spring(this.rb.body, this.connectedBody.body, {
|
|
18
|
-
// // localAnchorA: new CANNON.Vec3(-1, 1, 0),
|
|
19
|
-
// // localAnchorB: new CANNON.Vec3(0, 0, 0),
|
|
20
|
-
// // restLength: -.1,
|
|
21
|
-
// // stiffness: 10,
|
|
22
|
-
// // damping: .2,
|
|
23
|
-
// restLength: 0.01,
|
|
24
|
-
// stiffness: this.spring*.5,
|
|
25
|
-
// damping: this.damper,
|
|
26
|
-
// // localAnchorA: new CANNON.Vec3(this.anchor.x, this.anchor.y, this.anchor.z),
|
|
27
|
-
// // localAnchorB: new CANNON.Vec3(
|
|
28
|
-
// // this.connectedAnchor.x,
|
|
29
|
-
// // this.connectedAnchor.y,
|
|
30
|
-
// // this.connectedAnchor.z
|
|
31
|
-
// // ),
|
|
32
|
-
// });
|
|
33
|
-
// this.context.physics.addPostStepListener(_ => {
|
|
34
|
-
// // const wp = this.connectedBody.worldPosition;
|
|
35
|
-
// // console.log(wp.y, this.connectedBody.body.position.y, this.rb.body.position.y);
|
|
36
|
-
// spring.applyForce();
|
|
37
|
-
// });
|
|
38
|
-
// }
|
|
39
|
-
// update(): void {
|
|
40
|
-
// // console.log(this.worldPosition.y)
|
|
41
|
-
// }
|
|
42
|
-
// }
|
|
43
|
-
//# sourceMappingURL=SpringJoint.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SpringJoint.js","sourceRoot":"","sources":["../../../engine-components/SpringJoint.ts"],"names":[],"mappings":";AAAA,uDAAuD;AACvD,2CAA2C;AAC3C,sCAAsC;AACtC,mCAAmC;AAEnC,+CAA+C;AAC/C,qCAAqC;AACrC,8CAA8C;AAC9C,8CAA8C;AAC9C,2BAA2B;AAC3B,2BAA2B;AAE3B,6CAA6C;AAE7C,sBAAsB;AACtB,yEAAyE;AACzE,mGAAmG;AACnG,wGAAwG;AACxG,oFAAoF;AACpF,0DAA0D;AAC1D,yDAAyD;AACzD,kCAAkC;AAClC,gCAAgC;AAChC,8BAA8B;AAC9B,gCAAgC;AAChC,yCAAyC;AACzC,oCAAoC;AACpC,6FAA6F;AAC7F,gDAAgD;AAChD,6CAA6C;AAC7C,6CAA6C;AAC7C,4CAA4C;AAC5C,oBAAoB;AACpB,cAAc;AACd,0DAA0D;AAC1D,8DAA8D;AAC9D,iGAAiG;AACjG,mCAAmC;AACnC,cAAc;AACd,QAAQ;AAER,uBAAuB;AACvB,+CAA+C;AAC/C,QAAQ;AACR,IAAI"}
|
|
File without changes
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { serializable } from "../../engine/engine_serialization";
|
|
3
|
-
// import { Behaviour } from "../Component";
|
|
4
|
-
// export class CanvasScaler extends Behaviour {
|
|
5
|
-
// private _dynamicPixelsPerUnit: number = 1;
|
|
6
|
-
// @serializable()
|
|
7
|
-
// get dynamicPixelsPerUnit(): number {
|
|
8
|
-
// return this._dynamicPixelsPerUnit;
|
|
9
|
-
// }
|
|
10
|
-
// private set dynamicPixelsPerUnit(val: number) {
|
|
11
|
-
// this._dynamicPixelsPerUnit = val;
|
|
12
|
-
// }
|
|
13
|
-
// awake() {
|
|
14
|
-
// console.log(this);
|
|
15
|
-
// }
|
|
16
|
-
// }
|
|
17
|
-
//# sourceMappingURL=CanvasScaler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasScaler.js","sourceRoot":"","sources":["../../../../engine-components/ui/CanvasScaler.ts"],"names":[],"mappings":";AAAA,oEAAoE;AACpE,4CAA4C;AAG5C,gDAAgD;AAEhD,iDAAiD;AAEjD,sBAAsB;AACtB,2CAA2C;AAC3C,6CAA6C;AAC7C,QAAQ;AAER,sDAAsD;AACtD,4CAA4C;AAC5C,QAAQ;AAER,gBAAgB;AAChB,6BAA6B;AAC7B,QAAQ;AACR,IAAI"}
|
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.textureToCanvas = exports.copyTexture = exports.Graphics = exports.logHierarchy = exports.setWorldRotationXYZ = exports.setWorldRotation = exports.getWorldRotation = exports.setWorldEuler = exports.getWorldEuler = exports.forward = exports.setWorldScale = exports.getWorldScale = exports.setWorldQuaternionXYZW = exports.setWorldQuaternion = exports.getWorldQuaternion = exports.setWorldPositionXYZ = exports.setWorldPosition = exports.getWorldPosition = exports.lookAtInverse = void 0;
|
|
4
|
-
var THREE = require("three");
|
|
5
|
-
var engine_math_1 = require("./engine_math");
|
|
6
|
-
var three_1 = require("three");
|
|
7
|
-
var engine_utils_1 = require("./engine_utils");
|
|
8
|
-
var flipYQuat = new three_1.Quaternion().setFromAxisAngle(new three_1.Vector3(0, 1, 0), Math.PI);
|
|
9
|
-
function lookAtInverse(obj, target) {
|
|
10
|
-
obj.lookAt(target);
|
|
11
|
-
obj.quaternion.multiply(flipYQuat);
|
|
12
|
-
}
|
|
13
|
-
exports.lookAtInverse = lookAtInverse;
|
|
14
|
-
var _worldPositions = new engine_utils_1.CircularBuffer(function () { return new THREE.Vector3(); }, 100);
|
|
15
|
-
function getWorldPosition(obj, vec, updateParents) {
|
|
16
|
-
if (vec === void 0) { vec = null; }
|
|
17
|
-
if (updateParents === void 0) { updateParents = true; }
|
|
18
|
-
var wp = vec !== null && vec !== void 0 ? vec : _worldPositions.get();
|
|
19
|
-
if (!obj)
|
|
20
|
-
return wp.set(0, 0, 0);
|
|
21
|
-
if (!obj.parent)
|
|
22
|
-
return wp.copy(obj.position);
|
|
23
|
-
if (updateParents)
|
|
24
|
-
obj.updateWorldMatrix(true, false);
|
|
25
|
-
if (obj.matrixWorldNeedsUpdate)
|
|
26
|
-
obj.updateMatrixWorld();
|
|
27
|
-
wp.setFromMatrixPosition(obj.matrixWorld);
|
|
28
|
-
return wp;
|
|
29
|
-
}
|
|
30
|
-
exports.getWorldPosition = getWorldPosition;
|
|
31
|
-
function setWorldPosition(obj, val) {
|
|
32
|
-
var _a;
|
|
33
|
-
if (!obj)
|
|
34
|
-
return;
|
|
35
|
-
var wp = _worldPositions.get();
|
|
36
|
-
if (val !== wp)
|
|
37
|
-
wp.copy(val);
|
|
38
|
-
var obj2 = (_a = obj === null || obj === void 0 ? void 0 : obj.parent) !== null && _a !== void 0 ? _a : obj;
|
|
39
|
-
obj2.worldToLocal(wp);
|
|
40
|
-
obj.position.set(wp.x, wp.y, wp.z);
|
|
41
|
-
}
|
|
42
|
-
exports.setWorldPosition = setWorldPosition;
|
|
43
|
-
function setWorldPositionXYZ(obj, x, y, z) {
|
|
44
|
-
var wp = _worldPositions.get();
|
|
45
|
-
wp.set(x, y, z);
|
|
46
|
-
setWorldPosition(obj, wp);
|
|
47
|
-
}
|
|
48
|
-
exports.setWorldPositionXYZ = setWorldPositionXYZ;
|
|
49
|
-
var _worldQuaternionBuffer = new THREE.Quaternion();
|
|
50
|
-
var _worldQuaternion = new THREE.Quaternion();
|
|
51
|
-
var _tempQuaternionBuffer2 = new THREE.Quaternion();
|
|
52
|
-
function getWorldQuaternion(obj, target) {
|
|
53
|
-
if (target === void 0) { target = null; }
|
|
54
|
-
if (!obj)
|
|
55
|
-
return _worldQuaternion.set(0, 0, 0, 1);
|
|
56
|
-
var quat = target !== null && target !== void 0 ? target : _worldQuaternion;
|
|
57
|
-
if (!obj.parent)
|
|
58
|
-
return quat.copy(obj.quaternion);
|
|
59
|
-
obj.getWorldQuaternion(quat);
|
|
60
|
-
return quat;
|
|
61
|
-
}
|
|
62
|
-
exports.getWorldQuaternion = getWorldQuaternion;
|
|
63
|
-
function setWorldQuaternion(obj, val) {
|
|
64
|
-
if (!obj)
|
|
65
|
-
return;
|
|
66
|
-
if (val !== _worldQuaternionBuffer)
|
|
67
|
-
_worldQuaternionBuffer.copy(val);
|
|
68
|
-
var tempVec = _worldQuaternionBuffer;
|
|
69
|
-
var parent = obj === null || obj === void 0 ? void 0 : obj.parent;
|
|
70
|
-
parent === null || parent === void 0 ? void 0 : parent.getWorldQuaternion(_tempQuaternionBuffer2);
|
|
71
|
-
_tempQuaternionBuffer2.invert();
|
|
72
|
-
var q = _tempQuaternionBuffer2.multiply(tempVec);
|
|
73
|
-
// console.log(tempVec);
|
|
74
|
-
obj.quaternion.set(q.x, q.y, q.z, q.w);
|
|
75
|
-
// console.error("quaternion world to local is not yet implemented");
|
|
76
|
-
}
|
|
77
|
-
exports.setWorldQuaternion = setWorldQuaternion;
|
|
78
|
-
function setWorldQuaternionXYZW(obj, x, y, z, w) {
|
|
79
|
-
_worldQuaternionBuffer.set(x, y, z, w);
|
|
80
|
-
setWorldQuaternion(obj, _worldQuaternionBuffer);
|
|
81
|
-
}
|
|
82
|
-
exports.setWorldQuaternionXYZW = setWorldQuaternionXYZW;
|
|
83
|
-
var _worldScale = new THREE.Vector3();
|
|
84
|
-
var _worldScale2 = new THREE.Vector3();
|
|
85
|
-
function getWorldScale(obj, vec) {
|
|
86
|
-
if (vec === void 0) { vec = null; }
|
|
87
|
-
if (!obj)
|
|
88
|
-
return _worldScale.set(0, 0, 0);
|
|
89
|
-
if (!obj.parent)
|
|
90
|
-
return _worldScale.copy(obj.position);
|
|
91
|
-
obj.getWorldScale(vec !== null && vec !== void 0 ? vec : _worldScale);
|
|
92
|
-
return vec !== null && vec !== void 0 ? vec : _worldScale;
|
|
93
|
-
}
|
|
94
|
-
exports.getWorldScale = getWorldScale;
|
|
95
|
-
function setWorldScale(obj, vec) {
|
|
96
|
-
if (!obj)
|
|
97
|
-
return;
|
|
98
|
-
if (!obj.parent) {
|
|
99
|
-
obj.scale.copy(vec);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
var tempVec = _worldScale2;
|
|
103
|
-
var obj2 = obj.parent;
|
|
104
|
-
obj2.getWorldScale(tempVec);
|
|
105
|
-
tempVec.divide(vec);
|
|
106
|
-
obj.scale.copy(tempVec);
|
|
107
|
-
}
|
|
108
|
-
exports.setWorldScale = setWorldScale;
|
|
109
|
-
var _forward = new THREE.Vector3();
|
|
110
|
-
var _forwardQuat = new THREE.Quaternion();
|
|
111
|
-
function forward(obj) {
|
|
112
|
-
getWorldQuaternion(obj, _forwardQuat);
|
|
113
|
-
return _forward.set(0, 0, 1).applyQuaternion(_forwardQuat);
|
|
114
|
-
}
|
|
115
|
-
exports.forward = forward;
|
|
116
|
-
var _worldEulerBuffer = new THREE.Euler();
|
|
117
|
-
var _worldEuler = new THREE.Euler();
|
|
118
|
-
var _worldRotation = new THREE.Vector3();
|
|
119
|
-
// world euler (in radians)
|
|
120
|
-
function getWorldEuler(obj) {
|
|
121
|
-
obj.getWorldQuaternion(_worldQuaternion);
|
|
122
|
-
_worldEuler.setFromQuaternion(_worldQuaternion);
|
|
123
|
-
return _worldEuler;
|
|
124
|
-
}
|
|
125
|
-
exports.getWorldEuler = getWorldEuler;
|
|
126
|
-
// world euler (in radians)
|
|
127
|
-
function setWorldEuler(obj, val) {
|
|
128
|
-
setWorldQuaternion(obj, _worldQuaternion.setFromEuler(val));
|
|
129
|
-
;
|
|
130
|
-
}
|
|
131
|
-
exports.setWorldEuler = setWorldEuler;
|
|
132
|
-
// returns rotation in degrees
|
|
133
|
-
function getWorldRotation(obj) {
|
|
134
|
-
var rot = getWorldEuler(obj);
|
|
135
|
-
var wr = _worldRotation;
|
|
136
|
-
wr.set(rot.x, rot.y, rot.z);
|
|
137
|
-
wr.x = engine_math_1.Mathf.toDegrees(wr.x);
|
|
138
|
-
wr.y = engine_math_1.Mathf.toDegrees(wr.y);
|
|
139
|
-
wr.z = engine_math_1.Mathf.toDegrees(wr.z);
|
|
140
|
-
return wr;
|
|
141
|
-
}
|
|
142
|
-
exports.getWorldRotation = getWorldRotation;
|
|
143
|
-
function setWorldRotation(obj, val) {
|
|
144
|
-
setWorldRotationXYZ(obj, val.x, val.y, val.z, true);
|
|
145
|
-
}
|
|
146
|
-
exports.setWorldRotation = setWorldRotation;
|
|
147
|
-
function setWorldRotationXYZ(obj, x, y, z, degrees) {
|
|
148
|
-
if (degrees === void 0) { degrees = true; }
|
|
149
|
-
if (degrees) {
|
|
150
|
-
x = engine_math_1.Mathf.toRadians(x);
|
|
151
|
-
y = engine_math_1.Mathf.toRadians(y);
|
|
152
|
-
z = engine_math_1.Mathf.toRadians(z);
|
|
153
|
-
}
|
|
154
|
-
_worldEulerBuffer.set(x, y, z);
|
|
155
|
-
_worldQuaternionBuffer.setFromEuler(_worldEulerBuffer);
|
|
156
|
-
setWorldQuaternion(obj, _worldQuaternionBuffer);
|
|
157
|
-
}
|
|
158
|
-
exports.setWorldRotationXYZ = setWorldRotationXYZ;
|
|
159
|
-
// from https://github.com/mrdoob/three.js/pull/10995#issuecomment-287614722
|
|
160
|
-
function logHierarchy(root, collapsible) {
|
|
161
|
-
if (collapsible === void 0) { collapsible = true; }
|
|
162
|
-
if (!root)
|
|
163
|
-
return;
|
|
164
|
-
if (collapsible) {
|
|
165
|
-
(function printGraph(obj) {
|
|
166
|
-
console.groupCollapsed((obj.name ? obj.name : '(no name : ' + obj.type + ')') + ' %o', obj);
|
|
167
|
-
obj.children.forEach(printGraph);
|
|
168
|
-
console.groupEnd();
|
|
169
|
-
}(root));
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
root.traverse(function (obj) {
|
|
173
|
-
var s = '|___';
|
|
174
|
-
var obj2 = obj;
|
|
175
|
-
while (obj2.parent !== null) {
|
|
176
|
-
s = '\t' + s;
|
|
177
|
-
obj2 = obj2.parent;
|
|
178
|
-
}
|
|
179
|
-
console.log(s + obj.name + ' <' + obj.type + '>');
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
;
|
|
183
|
-
}
|
|
184
|
-
exports.logHierarchy = logHierarchy;
|
|
185
|
-
var Graphics = /** @class */ (function () {
|
|
186
|
-
function Graphics() {
|
|
187
|
-
}
|
|
188
|
-
Graphics.createBlitMaterial = function (fragment) {
|
|
189
|
-
return new three_1.ShaderMaterial({
|
|
190
|
-
uniforms: { map: new three_1.Uniform(null) },
|
|
191
|
-
vertexShader: this.vertex,
|
|
192
|
-
fragmentShader: fragment
|
|
193
|
-
});
|
|
194
|
-
};
|
|
195
|
-
Graphics.copyTexture = function (texture, blitMaterial) {
|
|
196
|
-
var material = blitMaterial !== null && blitMaterial !== void 0 ? blitMaterial : this.blipMaterial;
|
|
197
|
-
material.uniforms.map.value = texture;
|
|
198
|
-
material.needsUpdate = true;
|
|
199
|
-
material.uniformsNeedUpdate = true;
|
|
200
|
-
var mesh = this.mesh;
|
|
201
|
-
mesh.material = material;
|
|
202
|
-
mesh.frustumCulled = false;
|
|
203
|
-
this.scene.children.length = 0;
|
|
204
|
-
this.scene.add(mesh);
|
|
205
|
-
this.renderer.setSize(texture.image.width, texture.image.height);
|
|
206
|
-
this.renderer.clear();
|
|
207
|
-
this.renderer.render(this.scene, this.perspectiveCam);
|
|
208
|
-
var tex = new three_1.Texture(this.renderer.domElement);
|
|
209
|
-
tex.name = "Copy";
|
|
210
|
-
tex.needsUpdate = true; // < important!
|
|
211
|
-
return tex;
|
|
212
|
-
};
|
|
213
|
-
// static blit(src: Texture, target: Texture, blitMaterial?: ShaderMaterial) {
|
|
214
|
-
// let material = blitMaterial ?? this.blipMaterial;
|
|
215
|
-
// material.uniforms.map.value = src;
|
|
216
|
-
// this.mesh.material = material;
|
|
217
|
-
// this.mesh.frustumCulled = false;
|
|
218
|
-
// this.mesh.matrix.identity();
|
|
219
|
-
// this.scene.children.length = 0;
|
|
220
|
-
// this.scene.add(this.mesh);
|
|
221
|
-
// this.renderer.setSize(src.image.width, src.image.height);
|
|
222
|
-
// this.renderer.clear();
|
|
223
|
-
// this.renderer.render(this.scene, this.perspectiveCam);
|
|
224
|
-
// return new Texture(this.renderer.domElement);
|
|
225
|
-
// }
|
|
226
|
-
Graphics.textureToCanvas = function (texture, force) {
|
|
227
|
-
if (!texture)
|
|
228
|
-
return null;
|
|
229
|
-
if (force === true || texture["isCompressedTexture"] === true) {
|
|
230
|
-
texture = copyTexture(texture);
|
|
231
|
-
}
|
|
232
|
-
var image = texture.image;
|
|
233
|
-
if (isImageBitmap(image)) {
|
|
234
|
-
var canvas = document.createElement('canvas');
|
|
235
|
-
canvas.width = image.width;
|
|
236
|
-
canvas.height = image.height;
|
|
237
|
-
var context = canvas.getContext('2d');
|
|
238
|
-
if (!context) {
|
|
239
|
-
console.error("Failed getting canvas 2d context");
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
context.drawImage(image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height);
|
|
243
|
-
return canvas;
|
|
244
|
-
}
|
|
245
|
-
return null;
|
|
246
|
-
};
|
|
247
|
-
Graphics.planeGeometry = new THREE.PlaneGeometry(2, 2, 1, 1);
|
|
248
|
-
Graphics.renderer = new three_1.WebGLRenderer({ antialias: false });
|
|
249
|
-
Graphics.perspectiveCam = new THREE.PerspectiveCamera();
|
|
250
|
-
Graphics.scene = new THREE.Scene();
|
|
251
|
-
Graphics.vertex = "\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = vec4(position.xy * 1.0,0.,.999999);\n }";
|
|
252
|
-
Graphics.fragment = "\n uniform sampler2D map; \n varying vec2 vUv;\n void main(){ \n vec2 uv = vUv;\n uv.y = 1.0 - uv.y;\n gl_FragColor = texture2D( map, uv);\n gl_FragColor = vec4(uv.xy, 0, 1);\n }";
|
|
253
|
-
Graphics.blipMaterial = new three_1.ShaderMaterial({
|
|
254
|
-
uniforms: { map: new three_1.Uniform(null) },
|
|
255
|
-
vertexShader: this.vertex,
|
|
256
|
-
fragmentShader: this.fragment
|
|
257
|
-
});
|
|
258
|
-
Graphics.mesh = new THREE.Mesh(this.planeGeometry, this.blipMaterial);
|
|
259
|
-
return Graphics;
|
|
260
|
-
}());
|
|
261
|
-
exports.Graphics = Graphics;
|
|
262
|
-
/**@obsolete use Graphics.copyTexture */
|
|
263
|
-
function copyTexture(texture) {
|
|
264
|
-
return Graphics.copyTexture(texture);
|
|
265
|
-
}
|
|
266
|
-
exports.copyTexture = copyTexture;
|
|
267
|
-
/**@obsolete use Graphics.textureToCanvas */
|
|
268
|
-
function textureToCanvas(texture, force) {
|
|
269
|
-
if (force === void 0) { force = false; }
|
|
270
|
-
return Graphics.textureToCanvas(texture, force);
|
|
271
|
-
}
|
|
272
|
-
exports.textureToCanvas = textureToCanvas;
|
|
273
|
-
;
|
|
274
|
-
function isImageBitmap(image) {
|
|
275
|
-
return (typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement) ||
|
|
276
|
-
(typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement) ||
|
|
277
|
-
(typeof OffscreenCanvas !== 'undefined' && image instanceof OffscreenCanvas) ||
|
|
278
|
-
(typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap);
|
|
279
|
-
}
|
|
File without changes
|