@needle-tools/engine 3.4.0-alpha → 3.5.1-alpha
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 +14 -0
- package/dist/needle-engine.js +59388 -59097
- package/dist/needle-engine.min.js +416 -391
- package/dist/needle-engine.umd.cjs +388 -363
- package/lib/engine/api.d.ts +1 -0
- package/lib/engine/api.js +1 -0
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/engine_context.d.ts +9 -4
- package/lib/engine/engine_context.js +57 -32
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_context_registry.d.ts +5 -3
- package/lib/engine/engine_context_registry.js +10 -2
- package/lib/engine/engine_context_registry.js.map +1 -1
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_element_loading.js +2 -3
- package/lib/engine/engine_element_loading.js.map +1 -1
- package/lib/engine/engine_input.d.ts +2 -2
- package/lib/engine/engine_physics.d.ts +20 -93
- package/lib/engine/engine_physics.js +20 -892
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_physics.types.js.map +1 -1
- package/lib/engine/engine_physics_rapier.d.ts +103 -0
- package/lib/engine/engine_physics_rapier.js +1003 -0
- package/lib/engine/engine_physics_rapier.js.map +1 -0
- package/lib/engine/engine_types.d.ts +50 -1
- package/lib/engine/engine_types.js +8 -0
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine-components/Collider.js +6 -6
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Joints.js +2 -2
- package/lib/engine-components/Joints.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.js +16 -7
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/Renderer.js +3 -4
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/RigidBody.d.ts +0 -1
- package/lib/engine-components/RigidBody.js +24 -30
- package/lib/engine-components/RigidBody.js.map +1 -1
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +52 -26
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.d.ts +8 -2
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +44 -7
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js.map +1 -1
- package/lib/engine-components/ui/Canvas.js +29 -16
- package/lib/engine-components/ui/Canvas.js.map +1 -1
- package/lib/engine-components/ui/Layout.js +10 -5
- package/lib/engine-components/ui/Layout.js.map +1 -1
- package/lib/engine-components/ui/RectTransform.js +8 -3
- package/lib/engine-components/ui/RectTransform.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/plugins/vite/config.js +2 -1
- package/plugins/vite/defines.js +30 -0
- package/plugins/vite/dependency-watcher.js +173 -0
- package/plugins/vite/editor-connection.js +37 -39
- package/plugins/vite/index.js +5 -1
- package/plugins/vite/reload.js +3 -1
- package/src/engine/api.ts +1 -0
- package/src/engine/codegen/register_types.js +2 -2
- package/src/engine/engine_context.ts +75 -42
- package/src/engine/engine_context_registry.ts +13 -6
- package/src/engine/engine_element.ts +2 -1
- package/src/engine/engine_element_loading.ts +2 -3
- package/src/engine/engine_input.ts +2 -2
- package/src/engine/engine_physics.ts +25 -1020
- package/src/engine/engine_physics.types.ts +1 -3
- package/src/engine/engine_physics_rapier.ts +1127 -0
- package/src/engine/engine_types.ts +66 -4
- package/src/engine-components/Collider.ts +6 -6
- package/src/engine-components/Joints.ts +2 -2
- package/src/engine-components/ReflectionProbe.ts +17 -7
- package/src/engine-components/Renderer.ts +5 -5
- package/src/engine-components/RendererLightmap.ts +1 -1
- package/src/engine-components/RigidBody.ts +24 -31
- package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +58 -29
- package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +51 -9
- package/src/engine-components/ui/Canvas.ts +29 -16
- package/src/engine-components/ui/Layout.ts +10 -5
- package/src/engine-components/ui/RectTransform.ts +9 -4
|
@@ -11,6 +11,7 @@ import { EventSystem } from "./EventSystem";
|
|
|
11
11
|
import * as ThreeMeshUI from 'three-mesh-ui'
|
|
12
12
|
import { getParam } from "../../engine/engine_utils";
|
|
13
13
|
import { LayoutGroup } from "./Layout";
|
|
14
|
+
import { Mathf } from "../../engine/engine_math";
|
|
14
15
|
|
|
15
16
|
export enum RenderMode {
|
|
16
17
|
ScreenSpaceOverlay = 0,
|
|
@@ -127,6 +128,9 @@ export class Canvas extends UIRootComponent implements ICanvas {
|
|
|
127
128
|
awake() {
|
|
128
129
|
//@ts-ignore
|
|
129
130
|
this.shadowComponent = this.gameObject;
|
|
131
|
+
this.previousParent = this.gameObject.parent;
|
|
132
|
+
if (debugLayout)
|
|
133
|
+
console.log("Canvas.Awake()", this.previousParent?.name + "/" + this.gameObject.name)
|
|
130
134
|
super.awake();
|
|
131
135
|
}
|
|
132
136
|
|
|
@@ -137,7 +141,8 @@ export class Canvas extends UIRootComponent implements ICanvas {
|
|
|
137
141
|
onEnable() {
|
|
138
142
|
super.onEnable();
|
|
139
143
|
this._updateRenderSettingsRoutine = undefined;
|
|
140
|
-
this.
|
|
144
|
+
this._lastMatrixWorld = new Matrix4();
|
|
145
|
+
this.onUpdateRenderMode();
|
|
141
146
|
document.addEventListener("resize", this._boundRenderSettingsChanged);
|
|
142
147
|
// We want to run AFTER all regular onBeforeRender callbacks
|
|
143
148
|
this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine);
|
|
@@ -185,9 +190,11 @@ export class Canvas extends UIRootComponent implements ICanvas {
|
|
|
185
190
|
}
|
|
186
191
|
|
|
187
192
|
onBeforeRenderRoutine = () => {
|
|
193
|
+
this.previousParent = this.gameObject.parent;
|
|
194
|
+
// console.log(this.previousParent?.name + "/" + this.gameObject.name);
|
|
195
|
+
|
|
188
196
|
if (this.renderOnTop) {
|
|
189
197
|
// This is just a test but in reality it should be combined with all world canvases with render on top in one render pass
|
|
190
|
-
this.previousParent = this.gameObject.parent;
|
|
191
198
|
this.gameObject.removeFromParent();
|
|
192
199
|
}
|
|
193
200
|
else {
|
|
@@ -201,8 +208,13 @@ export class Canvas extends UIRootComponent implements ICanvas {
|
|
|
201
208
|
}
|
|
202
209
|
|
|
203
210
|
onAfterRenderRoutine = () => {
|
|
204
|
-
if (this.
|
|
205
|
-
|
|
211
|
+
if ((this.screenspace || this.renderMode) && this.previousParent && this.context.mainCamera) {
|
|
212
|
+
if (this.screenspace) {
|
|
213
|
+
const camObj = this.context.mainCamera;
|
|
214
|
+
camObj?.add(this.gameObject);
|
|
215
|
+
} else {
|
|
216
|
+
this.previousParent.add(this.gameObject);
|
|
217
|
+
}
|
|
206
218
|
this.context.renderer.autoClear = false;
|
|
207
219
|
this.context.renderer.clearDepth();
|
|
208
220
|
this.onUpdateRenderMode(true);
|
|
@@ -212,6 +224,7 @@ export class Canvas extends UIRootComponent implements ICanvas {
|
|
|
212
224
|
EventSystem.ensureUpdateMeshUI(ThreeMeshUI, this.context);
|
|
213
225
|
this.context.renderer.render(this.gameObject, this.context.mainCamera);
|
|
214
226
|
this.context.renderer.autoClear = true;
|
|
227
|
+
this.previousParent.add(this.gameObject);
|
|
215
228
|
}
|
|
216
229
|
this._lastMatrixWorld?.copy(this.gameObject.matrixWorld);
|
|
217
230
|
}
|
|
@@ -278,7 +291,10 @@ export class Canvas extends UIRootComponent implements ICanvas {
|
|
|
278
291
|
}
|
|
279
292
|
this._activeRenderMode = this._renderMode;
|
|
280
293
|
let camera = this.context.mainCameraComponent;
|
|
281
|
-
let planeDistance: number =
|
|
294
|
+
let planeDistance: number = 10;
|
|
295
|
+
if (camera && camera.nearClipPlane > 0 && camera.farClipPlane > 0) {
|
|
296
|
+
planeDistance = Mathf.lerp(camera.nearClipPlane, camera.farClipPlane, .5);
|
|
297
|
+
}
|
|
282
298
|
if (this._renderMode === RenderMode.ScreenSpaceCamera) {
|
|
283
299
|
if (this.worldCamera)
|
|
284
300
|
camera = this.worldCamera as Camera;
|
|
@@ -295,15 +311,12 @@ export class Canvas extends UIRootComponent implements ICanvas {
|
|
|
295
311
|
// showBalloonWarning("Screenspace Canvas is not supported yet. Please use worldspace");
|
|
296
312
|
if (!camera) return;
|
|
297
313
|
|
|
298
|
-
const canvas = this.gameObject;
|
|
299
|
-
const camObj = camera.gameObject;
|
|
300
|
-
camObj?.add(canvas);
|
|
301
314
|
// we move the plane SLIGHTLY closer to be sure not to cull the canvas
|
|
302
|
-
const plane = planeDistance
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
315
|
+
const plane = planeDistance + .01;
|
|
316
|
+
this.gameObject.position.x = 0;
|
|
317
|
+
this.gameObject.position.y = 0;
|
|
318
|
+
this.gameObject.position.z = -plane;
|
|
319
|
+
this.gameObject.quaternion.identity();
|
|
307
320
|
|
|
308
321
|
const rect = this.gameObject.getComponent(RectTransform)!;
|
|
309
322
|
let hasChanged = false;
|
|
@@ -316,10 +329,10 @@ export class Canvas extends UIRootComponent implements ICanvas {
|
|
|
316
329
|
|
|
317
330
|
const vFOV = camera.fieldOfView! * Math.PI / 180;
|
|
318
331
|
const h = 2 * Math.tan(vFOV / 2) * Math.abs(plane);
|
|
319
|
-
|
|
320
|
-
|
|
332
|
+
this.gameObject.scale.x = h / this.context.domHeight;
|
|
333
|
+
this.gameObject.scale.y = h / this.context.domHeight;
|
|
321
334
|
// Set scale.z, otherwise small offsets in screenspace mode have different visual results based on export scale and other settings
|
|
322
|
-
|
|
335
|
+
this.gameObject.scale.z = .01;
|
|
323
336
|
|
|
324
337
|
if (hasChanged) {
|
|
325
338
|
rect.sizeDelta.x = this.context.domWidth;
|
|
@@ -164,7 +164,8 @@ export abstract class HorizontalOrVerticalLayoutGroup extends LayoutGroup {
|
|
|
164
164
|
actualWidth -= this.padding.horizontal;
|
|
165
165
|
actualHeight -= this.padding.vertical;
|
|
166
166
|
|
|
167
|
-
//
|
|
167
|
+
// if (rect.name === "Title")
|
|
168
|
+
// console.log(rect.name, "width=" + totalWidth + ", height=" + totalHeight, rect.anchoredPosition.x)
|
|
168
169
|
|
|
169
170
|
const paddingAxis = axis === Axis.Horizontal ? this.padding.horizontal : this.padding.vertical;
|
|
170
171
|
const isHorizontal = axis === Axis.Horizontal;
|
|
@@ -243,7 +244,7 @@ export abstract class HorizontalOrVerticalLayoutGroup extends LayoutGroup {
|
|
|
243
244
|
}
|
|
244
245
|
|
|
245
246
|
// Apply layout
|
|
246
|
-
let k =
|
|
247
|
+
let k = 1;
|
|
247
248
|
for (let i = 0; i < this.gameObject.children.length; i++) {
|
|
248
249
|
const ch = this.gameObject.children[i];
|
|
249
250
|
const rt = GameObject.getComponent(ch, RectTransform);
|
|
@@ -269,10 +270,14 @@ export abstract class HorizontalOrVerticalLayoutGroup extends LayoutGroup {
|
|
|
269
270
|
let halfSize = size * .5;
|
|
270
271
|
start += halfSize;
|
|
271
272
|
|
|
273
|
+
// TODO: this isnt correct yet!
|
|
272
274
|
if (forceExpandSize) {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
275
|
+
// this is the center of the cell
|
|
276
|
+
let preferredStart = sizePerChild * k - sizePerChild * .5;
|
|
277
|
+
if (preferredStart > start) {
|
|
278
|
+
start = preferredStart - sizePerChild * .5 + size + this.padding.left;
|
|
279
|
+
start -= halfSize;
|
|
280
|
+
}
|
|
276
281
|
}
|
|
277
282
|
|
|
278
283
|
let value = start;
|
|
@@ -31,7 +31,7 @@ const tempQuaternion = new Quaternion();
|
|
|
31
31
|
|
|
32
32
|
export class RectTransform extends BaseUIComponent implements IRectTransform, IRectTransformChangedReceiver {
|
|
33
33
|
|
|
34
|
-
offset: number =
|
|
34
|
+
offset: number = .01;
|
|
35
35
|
|
|
36
36
|
// @serializable(Object3D)
|
|
37
37
|
// root? : Object3D;
|
|
@@ -103,7 +103,8 @@ export class RectTransform extends BaseUIComponent implements IRectTransform, IR
|
|
|
103
103
|
awake() {
|
|
104
104
|
super.awake();
|
|
105
105
|
this.lastMatrix = new Matrix4();
|
|
106
|
-
this.rectBlock = new Object3D()
|
|
106
|
+
this.rectBlock = new Object3D();
|
|
107
|
+
// Is this legacy? Not sure if this is still needed
|
|
107
108
|
this.rectBlock.position.z = .1;
|
|
108
109
|
this.rectBlock.name = this.name;
|
|
109
110
|
|
|
@@ -116,6 +117,8 @@ export class RectTransform extends BaseUIComponent implements IRectTransform, IR
|
|
|
116
117
|
onChange(this, "_anchoredPosition", () => { this.markDirty(); });
|
|
117
118
|
onChange(this, "sizeDelta", () => { this.markDirty(); });
|
|
118
119
|
onChange(this, "pivot", () => { this.markDirty(); });
|
|
120
|
+
onChange(this, "anchorMin", () => { this.markDirty(); });
|
|
121
|
+
onChange(this, "anchorMax", () => { this.markDirty(); });
|
|
119
122
|
|
|
120
123
|
// When exported with an anchored position offset we remove it here
|
|
121
124
|
// because it would otherwise be applied twice when the anchoring is animated
|
|
@@ -191,8 +194,10 @@ export class RectTransform extends BaseUIComponent implements IRectTransform, IR
|
|
|
191
194
|
|
|
192
195
|
const uiobject = this.shadowComponent;
|
|
193
196
|
if (!uiobject) return;
|
|
194
|
-
|
|
195
|
-
|
|
197
|
+
if (this.gameObject.parent)
|
|
198
|
+
this._parentRectTransform = GameObject.getComponentInParent(this.gameObject.parent, RectTransform) as RectTransform;
|
|
199
|
+
else
|
|
200
|
+
this._parentRectTransform = undefined;
|
|
196
201
|
this._transformNeedsUpdate = false;
|
|
197
202
|
this.lastMatrix.copy(this.gameObject.matrix);
|
|
198
203
|
|