@needle-tools/engine 2.53.0-pre → 2.55.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.
Files changed (199) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/needle-engine.d.ts +2477 -2267
  3. package/dist/needle-engine.js +425 -425
  4. package/dist/needle-engine.js.map +4 -4
  5. package/dist/needle-engine.min.js +40 -40
  6. package/dist/needle-engine.min.js.map +4 -4
  7. package/dist/needle-engine.tsbuildinfo +1 -0
  8. package/lib/engine/codegen/register_types.d.ts +1 -0
  9. package/lib/engine/codegen/register_types.js +346 -0
  10. package/lib/engine/codegen/register_types.js.map +1 -0
  11. package/lib/engine/debug/debug.d.ts +1 -0
  12. package/lib/engine/debug/debug.js +4 -0
  13. package/lib/engine/debug/debug.js.map +1 -1
  14. package/lib/engine/debug/debug_console.js +2 -1
  15. package/lib/engine/debug/debug_console.js.map +1 -1
  16. package/lib/engine/debug/debug_overlay.js +3 -1
  17. package/lib/engine/debug/debug_overlay.js.map +1 -1
  18. package/lib/engine/engine_default_parameters.d.ts +2 -2
  19. package/lib/engine/engine_element.js +4 -2
  20. package/lib/engine/engine_element.js.map +1 -1
  21. package/lib/engine/engine_element_loading.d.ts +1 -0
  22. package/lib/engine/engine_element_loading.js +17 -6
  23. package/lib/engine/engine_element_loading.js.map +1 -1
  24. package/lib/engine/engine_element_overlay.js +4 -2
  25. package/lib/engine/engine_element_overlay.js.map +1 -1
  26. package/lib/engine/engine_fileloader.d.ts +3 -0
  27. package/lib/engine/engine_fileloader.js +8 -0
  28. package/lib/engine/engine_fileloader.js.map +1 -0
  29. package/lib/engine/engine_generic_utils.d.ts +1 -0
  30. package/lib/engine/engine_generic_utils.js +14 -0
  31. package/lib/engine/engine_generic_utils.js.map +1 -0
  32. package/lib/engine/engine_input.js +4 -0
  33. package/lib/engine/engine_input.js.map +1 -1
  34. package/lib/engine/engine_lightdata.js +1 -1
  35. package/lib/engine/engine_lightdata.js.map +1 -1
  36. package/lib/engine/engine_mainloop_utils.js +8 -0
  37. package/lib/engine/engine_mainloop_utils.js.map +1 -1
  38. package/lib/engine/engine_networking_websocket.d.ts +1 -0
  39. package/lib/engine/engine_networking_websocket.js +1 -1
  40. package/lib/engine/engine_networking_websocket.js.map +1 -1
  41. package/lib/engine/engine_physics.d.ts +1 -1
  42. package/lib/engine/engine_physics.js +44 -3
  43. package/lib/engine/engine_physics.js.map +1 -1
  44. package/lib/engine/engine_physics.types.d.ts +13 -0
  45. package/lib/engine/engine_physics.types.js +7 -0
  46. package/lib/engine/engine_physics.types.js.map +1 -1
  47. package/lib/engine/engine_serialization_builtin_serializer.js +6 -3
  48. package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
  49. package/lib/engine/engine_setup.js +2 -2
  50. package/lib/engine/engine_setup.js.map +1 -1
  51. package/lib/engine/engine_time.d.ts +1 -0
  52. package/lib/engine/engine_time.js +7 -0
  53. package/lib/engine/engine_time.js.map +1 -1
  54. package/lib/engine/engine_types.d.ts +4 -1
  55. package/lib/engine/engine_types.js.map +1 -1
  56. package/lib/engine/engine_utils.d.ts +2 -1
  57. package/lib/engine/engine_utils.js +6 -0
  58. package/lib/engine/engine_utils.js.map +1 -1
  59. package/lib/engine/extensions/NEEDLE_components.d.ts +1 -1
  60. package/lib/engine/extensions/NEEDLE_progressive.d.ts +22 -0
  61. package/lib/engine/extensions/NEEDLE_progressive.js +172 -44
  62. package/lib/engine/extensions/NEEDLE_progressive.js.map +1 -1
  63. package/lib/engine-components/Collider.d.ts +2 -0
  64. package/lib/engine-components/Collider.js +4 -0
  65. package/lib/engine-components/Collider.js.map +1 -1
  66. package/lib/engine-components/GroundProjection.d.ts +2 -1
  67. package/lib/engine-components/GroundProjection.js +19 -12
  68. package/lib/engine-components/GroundProjection.js.map +1 -1
  69. package/lib/engine-components/ParticleSystem.d.ts +1 -0
  70. package/lib/engine-components/ParticleSystem.js +10 -5
  71. package/lib/engine-components/ParticleSystem.js.map +1 -1
  72. package/lib/engine-components/ParticleSystemModules.d.ts +2 -2
  73. package/lib/engine-components/ParticleSystemModules.js +65 -55
  74. package/lib/engine-components/ParticleSystemModules.js.map +1 -1
  75. package/lib/engine-components/ReflectionProbe.d.ts +1 -1
  76. package/lib/engine-components/Renderer.d.ts +2 -1
  77. package/lib/engine-components/Renderer.js +8 -8
  78. package/lib/engine-components/Renderer.js.map +1 -1
  79. package/lib/engine-components/RigidBody.js +1 -19
  80. package/lib/engine-components/RigidBody.js.map +1 -1
  81. package/lib/engine-components/SyncedTransform.js +1 -3
  82. package/lib/engine-components/SyncedTransform.js.map +1 -1
  83. package/lib/engine-components/VideoPlayer.d.ts +2 -1
  84. package/lib/engine-components/VideoPlayer.js +54 -51
  85. package/lib/engine-components/VideoPlayer.js.map +1 -1
  86. package/lib/engine-components/Volume.js +8 -1
  87. package/lib/engine-components/Volume.js.map +1 -1
  88. package/lib/engine-components/WebARSessionRoot.js +5 -0
  89. package/lib/engine-components/WebARSessionRoot.js.map +1 -1
  90. package/lib/engine-components/WebXR.d.ts +2 -2
  91. package/lib/engine-components/WebXR.js +13 -13
  92. package/lib/engine-components/WebXR.js.map +1 -1
  93. package/lib/engine-components/WebXRAvatar.d.ts +1 -1
  94. package/lib/engine-components/WebXRController.js +1 -2
  95. package/lib/engine-components/WebXRController.js.map +1 -1
  96. package/lib/engine-components/codegen/components.d.ts +99 -99
  97. package/lib/engine-components/codegen/components.js +99 -99
  98. package/lib/engine-components/codegen/components.js.map +1 -1
  99. package/lib/engine-components/export/usdz/USDZExporter.d.ts +1 -0
  100. package/lib/engine-components/export/usdz/USDZExporter.js +17 -1
  101. package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
  102. package/lib/engine-components/ui/Button.js +30 -0
  103. package/lib/engine-components/ui/Button.js.map +1 -1
  104. package/lib/engine-components/ui/InputField.d.ts +2 -0
  105. package/lib/engine-components/ui/InputField.js +23 -1
  106. package/lib/engine-components/ui/InputField.js.map +1 -1
  107. package/lib/engine-components/ui/Utils.d.ts +2 -0
  108. package/lib/engine-components/ui/Utils.js +10 -9
  109. package/lib/engine-components/ui/Utils.js.map +1 -1
  110. package/lib/engine-components-experimental/Presentation.d.ts +6 -0
  111. package/lib/engine-components-experimental/Presentation.js +11 -0
  112. package/lib/engine-components-experimental/Presentation.js.map +1 -0
  113. package/lib/engine-components-experimental/annotation/LineDrawer.d.ts +18 -0
  114. package/lib/engine-components-experimental/annotation/LineDrawer.js +175 -0
  115. package/lib/engine-components-experimental/annotation/LineDrawer.js.map +1 -0
  116. package/lib/engine-components-experimental/annotation/LinesManager.d.ts +54 -0
  117. package/lib/engine-components-experimental/annotation/LinesManager.js +155 -0
  118. package/lib/engine-components-experimental/annotation/LinesManager.js.map +1 -0
  119. package/lib/engine-components-experimental/networking/PlayerSync.d.ts +26 -0
  120. package/lib/engine-components-experimental/networking/PlayerSync.js +121 -0
  121. package/lib/engine-components-experimental/networking/PlayerSync.js.map +1 -0
  122. package/lib/engine-schemes/vec2.d.ts +10 -0
  123. package/lib/engine-schemes/vec2.js +26 -0
  124. package/lib/engine-schemes/vec2.js.map +1 -0
  125. package/lib/include/three/ARButton.d.ts +3 -0
  126. package/lib/include/three/ARButton.js +158 -0
  127. package/lib/include/three/ARButton.js.map +1 -0
  128. package/lib/include/three/EXT_mesh_gpu_instancing_exporter.d.ts +6 -0
  129. package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js +46 -0
  130. package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js.map +1 -0
  131. package/lib/include/three/VRButton.d.ts +5 -0
  132. package/lib/include/three/VRButton.js +122 -0
  133. package/lib/include/three/VRButton.js.map +1 -0
  134. package/lib/tsconfig.tsbuildinfo +1 -0
  135. package/package.json +1 -1
  136. package/src/engine/codegen/register_types.js +214 -214
  137. package/src/engine/debug/debug.ts +5 -0
  138. package/src/engine/debug/debug_console.ts +3 -2
  139. package/src/engine/debug/debug_overlay.ts +3 -1
  140. package/src/engine/engine_element.ts +4 -2
  141. package/src/engine/engine_element_loading.ts +13 -6
  142. package/src/engine/engine_element_overlay.ts +4 -2
  143. package/src/engine/engine_input.ts +4 -0
  144. package/src/engine/engine_lightdata.ts +1 -1
  145. package/src/engine/engine_mainloop_utils.ts +6 -0
  146. package/src/engine/engine_networking_websocket.ts +3 -1
  147. package/src/engine/engine_physics.ts +47 -5
  148. package/src/engine/engine_physics.types.ts +17 -0
  149. package/src/engine/engine_serialization_builtin_serializer.ts +8 -5
  150. package/src/engine/engine_setup.ts +2 -2
  151. package/src/engine/engine_time.ts +7 -1
  152. package/src/engine/engine_types.ts +5 -2
  153. package/src/engine/engine_utils.ts +7 -1
  154. package/src/engine/extensions/NEEDLE_progressive.ts +185 -43
  155. package/src/engine-components/Collider.ts +3 -0
  156. package/src/engine-components/GroundProjection.ts +18 -12
  157. package/src/engine-components/ParticleSystem.ts +10 -5
  158. package/src/engine-components/ParticleSystemModules.ts +69 -59
  159. package/src/engine-components/Renderer.ts +11 -9
  160. package/src/engine-components/RigidBody.ts +1 -20
  161. package/src/engine-components/SyncedTransform.ts +1 -3
  162. package/src/engine-components/VideoPlayer.ts +55 -51
  163. package/src/engine-components/Volume.ts +8 -1
  164. package/src/engine-components/WebARSessionRoot.ts +5 -0
  165. package/src/engine-components/WebXR.ts +17 -15
  166. package/src/engine-components/WebXRController.ts +1 -2
  167. package/src/engine-components/codegen/components.ts +99 -99
  168. package/src/engine-components/export/usdz/USDZExporter.ts +19 -2
  169. package/src/engine-components/ui/Button.ts +8 -8
  170. package/src/engine-components/ui/InputField.ts +25 -2
  171. package/src/engine-components/ui/Utils.ts +12 -11
  172. package/src/engine-components-experimental/annotation/LineDrawer.ts +10 -7
  173. package/src/engine-components-experimental/annotation/LinesManager.ts +6 -6
  174. package/src/engine-components-experimental/networking/PlayerSync.ts +1 -1
  175. package/lib/engine/engine_caching.d.ts +0 -0
  176. package/lib/engine/engine_caching.js +0 -2
  177. package/lib/engine/engine_caching.js.map +0 -1
  178. package/lib/engine/tests/simulate_avatars.d.ts +0 -0
  179. package/lib/engine/tests/simulate_avatars.js +0 -3
  180. package/lib/engine/tests/simulate_avatars.js.map +0 -1
  181. package/lib/engine-components/NavMesh.d.ts +0 -0
  182. package/lib/engine-components/NavMesh.js +0 -101
  183. package/lib/engine-components/NavMesh.js.map +0 -1
  184. package/lib/engine-components/ParticleSystemBehaviours.d.ts +0 -0
  185. package/lib/engine-components/ParticleSystemBehaviours.js +0 -2
  186. package/lib/engine-components/ParticleSystemBehaviours.js.map +0 -1
  187. package/lib/engine-components/SpringJoint.d.ts +0 -0
  188. package/lib/engine-components/SpringJoint.js +0 -43
  189. package/lib/engine-components/SpringJoint.js.map +0 -1
  190. package/lib/engine-components/ui/CanvasScaler.d.ts +0 -0
  191. package/lib/engine-components/ui/CanvasScaler.js +0 -17
  192. package/lib/engine-components/ui/CanvasScaler.js.map +0 -1
  193. package/src/engine/dist/engine_three_utils.js +0 -279
  194. package/src/engine/engine_caching.ts +0 -0
  195. package/src/engine/tests/simulate_avatars.ts +0 -2
  196. package/src/engine-components/NavMesh.ts +0 -117
  197. package/src/engine-components/ParticleSystemBehaviours.ts +0 -0
  198. package/src/engine-components/SpringJoint.ts +0 -45
  199. package/src/engine-components/ui/CanvasScaler.ts +0 -21
@@ -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"}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=ParticleSystemBehaviours.js.map
@@ -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
@@ -1,2 +0,0 @@
1
-
2
- // TODO
@@ -1,117 +0,0 @@
1
-
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
-
12
- // private pathfinding: Pathfinding | null = null;
13
- // private zones: string[] = [];
14
-
15
- // onEnable(): void {
16
-
17
- // this.pathfinding = new Pathfinding();
18
- // const ZONE = 'zone';
19
- // const geometries : THREE.BufferGeometry[] = [];
20
- // if (this.meshes && this.meshes.length > 0) {
21
- // for (let i = 0; i < this.meshes.length; i++) {
22
- // const obj = this.meshes[i] as THREE.Mesh;
23
- // if (!obj) continue;
24
- // const geo = obj.geometry;
25
- // if (!geo) continue;
26
- // const copy : THREE.BufferGeometry = {...geo};
27
- // // const copy = geo;
28
- // const attributesCopy = {...copy.attributes};
29
- // copy.attributes = attributesCopy;
30
- // if(attributesCopy.uv2) delete attributesCopy.uv2;
31
- // // copy.applyMatrix4(obj.matrixWorld);
32
- // geometries.push(copy);
33
- // // obj.updateMatrixWorld();
34
- // // singleGeometry.merge(geo);
35
- // // console.log(singleGeometry, geo);
36
- // }
37
- // }
38
- // const mesh = mergeBufferGeometries(geometries);
39
- // const zone = Pathfinding.createZone(mesh);
40
- // const name = ZONE;
41
- // this.zones.push(name);
42
- // this.pathfinding.setZoneData(name, zone);
43
-
44
- // // const target = new THREE.Vector3(2, 0, 2);
45
- // // const groupID = this.pathfinding.getGroup(ZONE, target);
46
- // // const path = this.pathfinding.findPath(this.worldPosition, target, ZONE, groupID);
47
- // // console.log(path, this.pathfinding);
48
- // }
49
-
50
- // public tryFindPath(from: THREE.Vector3, to: THREE.Vector3): THREE.Vector3[] | null {
51
- // const zone = this.zones[0];
52
- // const groupId = this.pathfinding.getGroup(zone, to);
53
- // const path = this.pathfinding.findPath(from, to, zone, groupId);
54
- // return path;
55
- // }
56
- // */
57
- // }
58
-
59
- // // import { input } from "../engine/engine_input";
60
- // import { Physics, RaycastOptions } from "../engine/engine_physics"
61
- // // import { time } from "../engine/engine_time";
62
- // // import { scene } from "../engine/engine_setup";
63
- // import {SyncedTransform} from "./SyncedTransform";
64
-
65
- // export class NavMeshAgent extends Behaviour {
66
- // /*
67
- // public navMesh: NavMesh | null = null;
68
-
69
- // private currentPath: THREE.Vector3[] | null = null;
70
- // private helper : PathfindingHelper | null = null;
71
-
72
- // onEnable(): void {
73
- // this.helper = new PathfindingHelper();
74
- // scene.add(this.helper);
75
- // }
76
-
77
- // update(): void {
78
- // if (input.mouseClick) {
79
- // if (this.navMesh) {
80
- // const from = this.worldPosition;
81
- // const opts = new RaycastOptions();
82
- // opts.setMask(RaycastOptions.AllLayers);
83
- // const hits = Physics.raycast(opts);
84
- // if (hits.length > 0) {
85
- // const to = hits[0].point;
86
- // this.helper.setPlayerPosition(from);
87
- // this.helper.setTargetPosition(to);
88
- // this.currentPath = this.navMesh.tryFindPath(from, to);
89
- // this.helper.setPath(this.currentPath);
90
- // // console.log(...this.currentPath);
91
-
92
- // const sync = GameObject.getComponent(this.gameObject, SyncedTransform);
93
- // if(sync) sync.requestOwnership();
94
- // }
95
- // }
96
- // }
97
-
98
- // if (this.currentPath && this.currentPath.length > 0) {
99
-
100
- // const wp = this.worldPosition;
101
- // const target = this.currentPath[0];
102
- // this.worldPosition = wp.lerp(target, time.deltaTime*2);
103
-
104
- // this.gameObject.lookAt(target);
105
- // // const vec = target.clone().sub(wp);
106
- // // const wr = this.worldQuaternion;
107
- // // wr.slerp(rot, time.deltaTime*5);
108
- // // this.worldQuaternion = wr;
109
-
110
- // if (wp.distanceTo(this.currentPath[0]) < 0.1)
111
- // this.currentPath.shift();
112
-
113
-
114
- // }
115
- // }
116
- // */
117
- // }
File without changes
@@ -1,45 +0,0 @@
1
- // import { Behaviour, GameObject } from "./Component";
2
- // import { Rigidbody } from "./RigidBody";
3
- // import * as CANNON from 'cannon-es'
4
- // import { Vector3 } from "three";
5
-
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
-
13
- // private rb : Rigidbody | null = null;
14
-
15
- // awake(): void {
16
- // this.rb = GameObject.getComponent(this.gameObject, Rigidbody);
17
- // if(!this.connectedBody || !this.connectedBody.body || !this.rb || !this.rb.body) return;
18
- // this.connectedBody.body.mass = Math.min(this.rb.body.mass*.99, this.connectedBody.body.mass);
19
- // const spring = new CANNON.Spring(this.rb.body, this.connectedBody.body, {
20
- // // localAnchorA: new CANNON.Vec3(-1, 1, 0),
21
- // // localAnchorB: new CANNON.Vec3(0, 0, 0),
22
- // // restLength: -.1,
23
- // // stiffness: 10,
24
- // // damping: .2,
25
- // restLength: 0.01,
26
- // stiffness: this.spring*.5,
27
- // damping: this.damper,
28
- // // localAnchorA: new CANNON.Vec3(this.anchor.x, this.anchor.y, this.anchor.z),
29
- // // localAnchorB: new CANNON.Vec3(
30
- // // this.connectedAnchor.x,
31
- // // this.connectedAnchor.y,
32
- // // this.connectedAnchor.z
33
- // // ),
34
- // });
35
- // this.context.physics.addPostStepListener(_ => {
36
- // // const wp = this.connectedBody.worldPosition;
37
- // // console.log(wp.y, this.connectedBody.body.position.y, this.rb.body.position.y);
38
- // spring.applyForce();
39
- // });
40
- // }
41
-
42
- // update(): void {
43
- // // console.log(this.worldPosition.y)
44
- // }
45
- // }
@@ -1,21 +0,0 @@
1
- // import { serializable } from "../../engine/engine_serialization";
2
- // import { Behaviour } from "../Component";
3
-
4
-
5
- // export class CanvasScaler extends Behaviour {
6
-
7
- // private _dynamicPixelsPerUnit: number = 1;
8
-
9
- // @serializable()
10
- // get dynamicPixelsPerUnit(): number {
11
- // return this._dynamicPixelsPerUnit;
12
- // }
13
-
14
- // private set dynamicPixelsPerUnit(val: number) {
15
- // this._dynamicPixelsPerUnit = val;
16
- // }
17
-
18
- // awake() {
19
- // console.log(this);
20
- // }
21
- // }