@needle-tools/engine 2.52.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.
Files changed (220) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/needle-engine.d.ts +3018 -2680
  3. package/dist/needle-engine.js +439 -439
  4. package/dist/needle-engine.js.map +4 -4
  5. package/dist/needle-engine.min.js +41 -41
  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_components.js +2 -2
  19. package/lib/engine/engine_components.js.map +1 -1
  20. package/lib/engine/engine_default_parameters.d.ts +2 -2
  21. package/lib/engine/engine_element.js +4 -2
  22. package/lib/engine/engine_element.js.map +1 -1
  23. package/lib/engine/engine_element_loading.d.ts +1 -0
  24. package/lib/engine/engine_element_loading.js +17 -6
  25. package/lib/engine/engine_element_loading.js.map +1 -1
  26. package/lib/engine/engine_element_overlay.js +4 -2
  27. package/lib/engine/engine_element_overlay.js.map +1 -1
  28. package/lib/engine/engine_fileloader.d.ts +3 -0
  29. package/lib/engine/engine_fileloader.js +8 -0
  30. package/lib/engine/engine_fileloader.js.map +1 -0
  31. package/lib/engine/engine_generic_utils.d.ts +1 -0
  32. package/lib/engine/engine_generic_utils.js +14 -0
  33. package/lib/engine/engine_generic_utils.js.map +1 -0
  34. package/lib/engine/engine_input.js +4 -0
  35. package/lib/engine/engine_input.js.map +1 -1
  36. package/lib/engine/engine_networking_instantiate.d.ts +1 -1
  37. package/lib/engine/engine_networking_instantiate.js +3 -0
  38. package/lib/engine/engine_networking_instantiate.js.map +1 -1
  39. package/lib/engine/engine_networking_websocket.d.ts +1 -0
  40. package/lib/engine/engine_networking_websocket.js +1 -1
  41. package/lib/engine/engine_networking_websocket.js.map +1 -1
  42. package/lib/engine/engine_serialization_builtin_serializer.d.ts +6 -0
  43. package/lib/engine/engine_serialization_builtin_serializer.js +35 -7
  44. package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
  45. package/lib/engine/engine_serialization_core.d.ts +1 -0
  46. package/lib/engine/engine_serialization_core.js +6 -0
  47. package/lib/engine/engine_serialization_core.js.map +1 -1
  48. package/lib/engine/engine_setup.js +2 -2
  49. package/lib/engine/engine_setup.js.map +1 -1
  50. package/lib/engine/engine_texture.d.ts +3 -0
  51. package/lib/engine/engine_texture.js +4 -0
  52. package/lib/engine/engine_texture.js.map +1 -0
  53. package/lib/engine/engine_utils.d.ts +1 -1
  54. package/lib/engine/engine_utils.js +3 -0
  55. package/lib/engine/engine_utils.js.map +1 -1
  56. package/lib/engine/extensions/NEEDLE_components.d.ts +1 -1
  57. package/lib/engine/extensions/NEEDLE_progressive.d.ts +40 -0
  58. package/lib/engine/extensions/NEEDLE_progressive.js +322 -0
  59. package/lib/engine/extensions/NEEDLE_progressive.js.map +1 -0
  60. package/lib/engine/extensions/extensions.js +2 -2
  61. package/lib/engine/extensions/extensions.js.map +1 -1
  62. package/lib/engine-components/Camera.js +17 -2
  63. package/lib/engine-components/Camera.js.map +1 -1
  64. package/lib/engine-components/GroundProjection.d.ts +2 -1
  65. package/lib/engine-components/GroundProjection.js +19 -12
  66. package/lib/engine-components/GroundProjection.js.map +1 -1
  67. package/lib/engine-components/Light.js +1 -0
  68. package/lib/engine-components/Light.js.map +1 -1
  69. package/lib/engine-components/OrbitControls.js +6 -2
  70. package/lib/engine-components/OrbitControls.js.map +1 -1
  71. package/lib/engine-components/ParticleSystemModules.d.ts +1 -1
  72. package/lib/engine-components/ParticleSystemModules.js +48 -44
  73. package/lib/engine-components/ParticleSystemModules.js.map +1 -1
  74. package/lib/engine-components/ReflectionProbe.d.ts +1 -1
  75. package/lib/engine-components/Renderer.d.ts +1 -1
  76. package/lib/engine-components/Renderer.js +4 -9
  77. package/lib/engine-components/Renderer.js.map +1 -1
  78. package/lib/engine-components/Voip.js +13 -4
  79. package/lib/engine-components/Voip.js.map +1 -1
  80. package/lib/engine-components/Volume.js +8 -1
  81. package/lib/engine-components/Volume.js.map +1 -1
  82. package/lib/engine-components/WebXR.d.ts +2 -2
  83. package/lib/engine-components/WebXRAvatar.d.ts +1 -1
  84. package/lib/engine-components/codegen/components.d.ts +99 -95
  85. package/lib/engine-components/codegen/components.js +99 -95
  86. package/lib/engine-components/codegen/components.js.map +1 -1
  87. package/lib/engine-components/export/{GltfExport.d.ts → gltf/GltfExport.d.ts} +2 -2
  88. package/lib/engine-components/export/{GltfExport.js → gltf/GltfExport.js} +7 -7
  89. package/lib/engine-components/export/gltf/GltfExport.js.map +1 -0
  90. package/lib/engine-components/export/usdz/Extension.d.ts +9 -0
  91. package/lib/engine-components/export/usdz/Extension.js +2 -0
  92. package/lib/engine-components/export/usdz/Extension.js.map +1 -0
  93. package/lib/engine-components/export/usdz/USDZExporter.d.ts +26 -0
  94. package/lib/engine-components/export/usdz/USDZExporter.js +209 -0
  95. package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -0
  96. package/lib/engine-components/export/usdz/extensions/Animation.d.ts +44 -0
  97. package/lib/engine-components/export/usdz/extensions/Animation.js +264 -0
  98. package/lib/engine-components/export/usdz/extensions/Animation.js.map +1 -0
  99. package/lib/engine-components/export/usdz/types.d.ts +34 -0
  100. package/lib/engine-components/export/usdz/types.js +2 -0
  101. package/lib/engine-components/export/usdz/types.js.map +1 -0
  102. package/lib/engine-components/export/usdz/utils/animationutils.d.ts +3 -0
  103. package/lib/engine-components/export/usdz/utils/animationutils.js +46 -0
  104. package/lib/engine-components/export/usdz/utils/animationutils.js.map +1 -0
  105. package/lib/engine-components/export/usdz/utils/quicklook.d.ts +2 -0
  106. package/lib/engine-components/export/usdz/utils/quicklook.js +36 -0
  107. package/lib/engine-components/export/usdz/utils/quicklook.js.map +1 -0
  108. package/lib/engine-components/export/usdz/utils/timeutils.d.ts +1 -0
  109. package/lib/engine-components/export/usdz/utils/timeutils.js +15 -0
  110. package/lib/engine-components/export/usdz/utils/timeutils.js.map +1 -0
  111. package/lib/engine-components/ui/Button.js +30 -0
  112. package/lib/engine-components/ui/Button.js.map +1 -1
  113. package/lib/engine-components/ui/Graphic.d.ts +2 -0
  114. package/lib/engine-components/ui/Graphic.js +15 -0
  115. package/lib/engine-components/ui/Graphic.js.map +1 -1
  116. package/lib/engine-components/ui/InputField.d.ts +2 -0
  117. package/lib/engine-components/ui/InputField.js +23 -1
  118. package/lib/engine-components/ui/InputField.js.map +1 -1
  119. package/lib/engine-components/ui/Utils.d.ts +4 -1
  120. package/lib/engine-components/ui/Utils.js +15 -12
  121. package/lib/engine-components/ui/Utils.js.map +1 -1
  122. package/lib/engine-components-experimental/Presentation.d.ts +6 -0
  123. package/lib/engine-components-experimental/Presentation.js +11 -0
  124. package/lib/engine-components-experimental/Presentation.js.map +1 -0
  125. package/lib/engine-components-experimental/annotation/LineDrawer.d.ts +18 -0
  126. package/lib/engine-components-experimental/annotation/LineDrawer.js +175 -0
  127. package/lib/engine-components-experimental/annotation/LineDrawer.js.map +1 -0
  128. package/lib/engine-components-experimental/annotation/LinesManager.d.ts +54 -0
  129. package/lib/engine-components-experimental/annotation/LinesManager.js +155 -0
  130. package/lib/engine-components-experimental/annotation/LinesManager.js.map +1 -0
  131. package/lib/engine-components-experimental/networking/PlayerSync.d.ts +26 -0
  132. package/lib/engine-components-experimental/networking/PlayerSync.js +121 -0
  133. package/lib/engine-components-experimental/networking/PlayerSync.js.map +1 -0
  134. package/lib/engine-schemes/vec2.d.ts +10 -0
  135. package/lib/engine-schemes/vec2.js +26 -0
  136. package/lib/engine-schemes/vec2.js.map +1 -0
  137. package/lib/include/three/ARButton.d.ts +3 -0
  138. package/lib/include/three/ARButton.js +158 -0
  139. package/lib/include/three/ARButton.js.map +1 -0
  140. package/lib/include/three/EXT_mesh_gpu_instancing_exporter.d.ts +6 -0
  141. package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js +46 -0
  142. package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js.map +1 -0
  143. package/lib/include/three/VRButton.d.ts +5 -0
  144. package/lib/include/three/VRButton.js +122 -0
  145. package/lib/include/three/VRButton.js.map +1 -0
  146. package/lib/tsconfig.tsbuildinfo +1 -0
  147. package/package.json +2 -2
  148. package/src/engine/codegen/register_types.js +212 -204
  149. package/src/engine/debug/debug.ts +5 -0
  150. package/src/engine/debug/debug_console.ts +3 -2
  151. package/src/engine/debug/debug_overlay.ts +3 -1
  152. package/src/engine/engine_components.ts +2 -2
  153. package/src/engine/engine_element.ts +4 -2
  154. package/src/engine/engine_element_loading.ts +13 -6
  155. package/src/engine/engine_element_overlay.ts +4 -2
  156. package/src/engine/engine_input.ts +4 -0
  157. package/src/engine/engine_networking_instantiate.ts +4 -1
  158. package/src/engine/engine_networking_websocket.ts +3 -1
  159. package/src/engine/engine_serialization_builtin_serializer.ts +39 -8
  160. package/src/engine/engine_serialization_core.ts +7 -1
  161. package/src/engine/engine_setup.ts +2 -2
  162. package/src/engine/engine_texture.ts +6 -0
  163. package/src/engine/engine_utils.ts +3 -1
  164. package/src/engine/extensions/NEEDLE_progressive.ts +357 -0
  165. package/src/engine/extensions/extensions.ts +2 -2
  166. package/src/engine-components/Camera.ts +17 -3
  167. package/src/engine-components/GroundProjection.ts +18 -12
  168. package/src/engine-components/Light.ts +3 -1
  169. package/src/engine-components/OrbitControls.ts +7 -3
  170. package/src/engine-components/ParticleSystemModules.ts +50 -47
  171. package/src/engine-components/Renderer.ts +6 -10
  172. package/src/engine-components/Voip.ts +14 -4
  173. package/src/engine-components/Volume.ts +8 -1
  174. package/src/engine-components/WebXR.ts +2 -2
  175. package/src/engine-components/codegen/components.ts +99 -95
  176. package/src/engine-components/export/{GltfExport.ts → gltf/GltfExport.ts} +7 -7
  177. package/src/engine-components/export/usdz/Extension.ts +12 -0
  178. package/src/engine-components/export/usdz/USDZExporter.ts +233 -0
  179. package/src/engine-components/export/usdz/extensions/Animation.ts +306 -0
  180. package/src/engine-components/export/usdz/types.ts +39 -0
  181. package/src/engine-components/export/usdz/utils/animationutils.ts +60 -0
  182. package/src/engine-components/export/usdz/utils/quicklook.ts +43 -0
  183. package/src/engine-components/export/usdz/utils/timeutils.ts +20 -0
  184. package/src/engine-components/ui/Button.ts +8 -8
  185. package/src/engine-components/ui/Graphic.ts +15 -1
  186. package/src/engine-components/ui/InputField.ts +25 -2
  187. package/src/engine-components/ui/Utils.ts +17 -14
  188. package/src/engine-components-experimental/annotation/LineDrawer.ts +10 -7
  189. package/src/engine-components-experimental/annotation/LinesManager.ts +6 -6
  190. package/src/engine-components-experimental/networking/PlayerSync.ts +1 -1
  191. package/lib/engine/engine_caching.d.ts +0 -0
  192. package/lib/engine/engine_caching.js +0 -2
  193. package/lib/engine/engine_caching.js.map +0 -1
  194. package/lib/engine/extensions/NEEDLE_deferred_texture.d.ts +0 -18
  195. package/lib/engine/extensions/NEEDLE_deferred_texture.js +0 -194
  196. package/lib/engine/extensions/NEEDLE_deferred_texture.js.map +0 -1
  197. package/lib/engine/tests/simulate_avatars.d.ts +0 -0
  198. package/lib/engine/tests/simulate_avatars.js +0 -3
  199. package/lib/engine/tests/simulate_avatars.js.map +0 -1
  200. package/lib/engine-components/NavMesh.d.ts +0 -0
  201. package/lib/engine-components/NavMesh.js +0 -101
  202. package/lib/engine-components/NavMesh.js.map +0 -1
  203. package/lib/engine-components/ParticleSystemBehaviours.d.ts +0 -0
  204. package/lib/engine-components/ParticleSystemBehaviours.js +0 -2
  205. package/lib/engine-components/ParticleSystemBehaviours.js.map +0 -1
  206. package/lib/engine-components/SpringJoint.d.ts +0 -0
  207. package/lib/engine-components/SpringJoint.js +0 -43
  208. package/lib/engine-components/SpringJoint.js.map +0 -1
  209. package/lib/engine-components/export/GltfExport.js.map +0 -1
  210. package/lib/engine-components/ui/CanvasScaler.d.ts +0 -0
  211. package/lib/engine-components/ui/CanvasScaler.js +0 -17
  212. package/lib/engine-components/ui/CanvasScaler.js.map +0 -1
  213. package/src/engine/dist/engine_three_utils.js +0 -279
  214. package/src/engine/engine_caching.ts +0 -0
  215. package/src/engine/extensions/NEEDLE_deferred_texture.ts +0 -217
  216. package/src/engine/tests/simulate_avatars.ts +0 -2
  217. package/src/engine-components/NavMesh.ts +0 -117
  218. package/src/engine-components/ParticleSystemBehaviours.ts +0 -0
  219. package/src/engine-components/SpringJoint.ts +0 -45
  220. package/src/engine-components/ui/CanvasScaler.ts +0 -21
@@ -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,217 +0,0 @@
1
- import { Material, Texture, TextureLoader } from "three";
2
- import { GLTF, GLTFLoader, GLTFLoaderPlugin, GLTFParser } from "three/examples/jsm/loaders/GLTFLoader";
3
- import { SourceIdentifier } from "../engine_types";
4
- import { Context } from "../engine_setup";
5
- import { addDracoAndKTX2Loaders } from "../engine_loaders";
6
- import { getParam, getPath } from "../engine_utils";
7
-
8
- export const EXTENSION_NAME = "NEEDLE_deferred_texture";
9
-
10
- const debug = getParam("debugprogressive");
11
-
12
- declare type DeferredTextureModel = {
13
- uri: string;
14
- guid: string;
15
- usage?: string,
16
- }
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
-
38
- export class NEEDLE_deferred_texture implements GLTFLoaderPlugin {
39
-
40
-
41
- static assignTextureLOD(context: Context, source: SourceIdentifier | undefined, material: Material, level: number = 0) {
42
- if (!material) return;
43
- for (let slot of Object.keys(material)) {
44
- const val = material[slot];
45
- if (val?.isTexture === true) {
46
-
47
- if (debug) console.log("-----------\n", "FIND", material.name, slot, val?.name, val?.userData, val, material);
48
-
49
- NEEDLE_deferred_texture.getOrLoadTexture(context, source, material, slot, val, level).then(t => {
50
- if (t?.isTexture === true) {
51
-
52
- if (debug) console.log("Assign LOD", material.name, slot, t.name, t["guid"], material, "Prev:", val, "Now:", t, "\n--------------");
53
-
54
- material[slot] = t;
55
- t.needsUpdate = true;
56
- material.needsUpdate = true;
57
-
58
- if (debug) {
59
- let debug_map = debug_toggle_maps.get(material);
60
- if (!debug_map) {
61
- debug_map = {};
62
- debug_toggle_maps.set(material, debug_map);
63
- }
64
- let entry = debug_map[slot];
65
- if (!entry) {
66
- entry = debug_map[slot] = { original: val, lod0: t };
67
- }
68
- entry.lod0 = t;
69
- }
70
- }
71
- });
72
- }
73
- }
74
- }
75
-
76
-
77
- get name(): string {
78
- return EXTENSION_NAME;
79
- }
80
-
81
- private parser: GLTFParser;
82
- private sourceId: SourceIdentifier;
83
- private context: Context;
84
-
85
- constructor(parser: GLTFParser, sourceId: SourceIdentifier, context: Context) {
86
- this.parser = parser;
87
- this.sourceId = sourceId;
88
- this.context = context;
89
- }
90
-
91
- private _loading: number[] = [];
92
-
93
- // beforeRoot(): null {
94
- // console.log("BEFORE ROOT", this.parser);
95
- // return null;
96
- // }
97
-
98
- // loadTexture(index: number): Promise<Texture> | null {
99
- // console.log(index, this._loading);
100
- // if (this._loading.includes(index)) return null;
101
- // const textureInfo = this.parser.json.textures[index];
102
- // if (debug)
103
- // console.log(index, textureInfo);
104
- // return null;
105
- // }
106
-
107
- afterRoot(gltf: GLTF): null {
108
- if (debug)
109
- console.log("AFTER", this.sourceId, gltf);
110
- this.parser.json.textures?.forEach((textureInfo, index) => {
111
- if (textureInfo?.extensions) {
112
- const ext: DeferredTextureModel = textureInfo?.extensions[EXTENSION_NAME];
113
- if (ext) {
114
- const prom = this.parser.getDependency("texture", index);
115
- this._loading.splice(this._loading.indexOf(index), 1);
116
- prom.then(t => {
117
- if (debug) console.log("register texture", t.name, t.uuid, ext);
118
- t.userData.deferred = ext;
119
- NEEDLE_deferred_texture.cache.set(t.uuid, ext);
120
- });
121
- }
122
- }
123
- });
124
-
125
- return null;
126
- }
127
-
128
- private static cache = new Map<string, DeferredTextureModel>();
129
- private static resolved: { [key: string]: Texture } = {};
130
-
131
- private static async getOrLoadTexture(context: Context, source: SourceIdentifier | undefined, material: Material, slot: string, current: Texture, _level: number): Promise<Texture | null> {
132
-
133
- const key = current.uuid;
134
- const ext: DeferredTextureModel | undefined = NEEDLE_deferred_texture.cache.get(key);// || current.userData.deferred;
135
- if (ext) {
136
- if (debug)
137
- console.log(key, ext.uri, ext.guid);
138
- const uri = getPath(source, ext.uri);
139
- if (uri.endsWith(".glb") || uri.endsWith(".gltf")) {
140
- if (!ext.guid) {
141
- console.warn("missing pointer for glb/gltf texture", ext);
142
- return null;
143
- }
144
- const resolveKey = uri + "_" + ext.guid;
145
- if (this.resolved[resolveKey]) {
146
- if (debug) console.log("Texture has already been loaded: " + resolveKey, material.name, slot, current.name);
147
- return this.resolved[resolveKey];
148
- }
149
-
150
- const loader = new GLTFLoader();
151
- addDracoAndKTX2Loaders(loader, context);
152
- if (debug) console.log("Load " + uri, material.name, slot, ext.guid);
153
- const gltf = await loader.loadAsync(uri);
154
- const parser = gltf.parser;
155
- if (debug) console.log("Loading finished " + uri, material.name, slot, ext.guid);
156
- let index = -1;
157
- let found = false;
158
- for (const tex of gltf.parser.json.textures) {
159
- index++;
160
- if (tex?.extensions) {
161
- const other: DeferredTextureModel = tex?.extensions[EXTENSION_NAME];
162
- if (other?.guid) {
163
- if (other.guid === ext.guid) {
164
- found = true;
165
- break;
166
- // if (debug)
167
- // console.log(material.name, slot, "change \"" + current.name + "\" → \"" + tex.name + "\"", uri, index, tex, material);
168
- // this.resolved[resolveKey] = tex as Texture;
169
- // return tex;
170
- }
171
- }
172
- }
173
- }
174
- if (!found)
175
- return null;
176
-
177
- // const index = Number.parseInt(ext.pointer.substring("textures/".length));
178
- const tex = await parser.getDependency("texture", index);
179
- tex.encoding = current.encoding;
180
- if (tex) {
181
- tex.guid = ext.guid;
182
- }
183
- this.resolved[resolveKey] = tex as Texture;
184
- if (debug)
185
- console.log(material.name, slot, "change \"" + current.name + "\" → \"" + tex.name + "\"", uri, index, tex, material, resolveKey);
186
- return tex;
187
- }
188
- else {
189
- if (debug) console.log("Load texture from uri: " + uri);
190
- const loader = new TextureLoader();
191
- const loaded = await loader.loadAsync(uri);
192
- if (loaded && debug) {
193
- console.log(ext, loaded);
194
- }
195
- else console.warn("failed loading", uri);
196
- return loaded;
197
- }
198
- // loader.then((h: Texture) => {
199
- // // console.log(t, h);
200
- // // t.image = h.image;
201
- // // // this.context.renderer.copyTextureToTexture(new Vector2(0, 0), h, t);
202
- // // // console.log(h);
203
-
204
- // // // t.source = h.source;
205
- // // // t.version++;
206
- // // t.width = h.width;
207
- // // t.height = h.height;
208
- // // t.needsUpdate = true;
209
- // });
210
- }
211
- else {
212
- if (debug)
213
- console.warn("unknown uuid", current.name, current.uuid, current);
214
- }
215
- return null;
216
- }
217
- }
@@ -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
- // }