@needle-tools/engine 3.5.0-alpha → 3.5.2-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 +11 -0
- package/dist/needle-engine.js +10447 -10303
- package/dist/needle-engine.min.js +375 -372
- package/dist/needle-engine.umd.cjs +319 -316
- package/lib/engine/codegen/register_types.js +0 -2
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/engine_context.d.ts +8 -3
- package/lib/engine/engine_context.js +36 -17
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_element_loading.js +2 -2
- package/lib/engine/engine_element_loading.js.map +1 -1
- package/lib/engine/engine_license.d.ts +2 -0
- package/lib/engine/engine_license.js +25 -4
- package/lib/engine/engine_license.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/SceneSwitcher.d.ts +9 -0
- package/lib/engine-components/SceneSwitcher.js +128 -0
- package/lib/engine-components/SceneSwitcher.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +0 -1
- package/lib/engine-components/codegen/components.js +0 -1
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.d.ts +9 -5
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +25 -11
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js.map +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.d.ts +1 -0
- package/lib/engine-components/export/usdz/USDZExporter.js +14 -5
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.d.ts +1 -5
- package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.js +1 -10
- package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +4 -4
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.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 +9 -6
- package/lib/engine-components/ui/RectTransform.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/plugins/vite/license.js +2 -2
- package/src/engine/codegen/register_types.js +2 -4
- package/src/engine/engine_context.ts +43 -19
- package/src/engine/engine_element_loading.ts +2 -2
- package/src/engine/engine_license.ts +25 -4
- 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/SceneSwitcher.ts +136 -1
- package/src/engine-components/codegen/components.ts +0 -1
- package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +38 -12
- package/src/engine-components/export/usdz/USDZExporter.ts +14 -7
- package/src/engine-components/export/usdz/extensions/behavior/Behaviour.ts +5 -15
- package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +19 -19
- package/src/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.ts +2 -2
- 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 +10 -6
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { GameObject } from "../../../../Component";
|
|
2
|
+
import { IContext } from "../../../../../engine/engine_types";
|
|
3
3
|
import { IUSDExporterExtension } from "../../Extension";
|
|
4
4
|
import { USDObject, USDWriter } from "../../ThreeUSDZExporter";
|
|
5
5
|
import { BehaviorModel } from "./BehavioursBuilder";
|
|
6
|
-
import { IContext } from "../../../../../engine/engine_types";
|
|
7
6
|
|
|
8
7
|
export interface UsdzBehaviour {
|
|
9
8
|
createBehaviours?(ext: BehaviorExtension, model: USDObject, context: IContext): void;
|
|
@@ -11,15 +10,6 @@ export interface UsdzBehaviour {
|
|
|
11
10
|
afterCreateDocument?(ext: BehaviorExtension, context: IContext): void;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
export class USDZBehaviours extends Behaviour {
|
|
15
|
-
start() {
|
|
16
|
-
const exporter = GameObject.findObjectOfType(USDZExporter);
|
|
17
|
-
if (exporter) {
|
|
18
|
-
exporter.extensions.push(new BehaviorExtension());
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
13
|
export class BehaviorExtension implements IUSDExporterExtension {
|
|
24
14
|
|
|
25
15
|
get extensionName(): string {
|
|
@@ -40,8 +30,8 @@ export class BehaviorExtension implements IUSDExporterExtension {
|
|
|
40
30
|
GameObject.foreachComponent(e, (comp) => {
|
|
41
31
|
const c = comp as unknown as UsdzBehaviour;
|
|
42
32
|
if (
|
|
43
|
-
typeof c.createBehaviours === "function" ||
|
|
44
|
-
typeof c.beforeCreateDocument === "function" ||
|
|
33
|
+
typeof c.createBehaviours === "function" ||
|
|
34
|
+
typeof c.beforeCreateDocument === "function" ||
|
|
45
35
|
typeof c.afterCreateDocument === "function"
|
|
46
36
|
) {
|
|
47
37
|
this.behaviourComponents.push(c);
|
|
@@ -66,7 +56,7 @@ export class BehaviorExtension implements IUSDExporterExtension {
|
|
|
66
56
|
this.behaviourComponents.length = 0;
|
|
67
57
|
}
|
|
68
58
|
|
|
69
|
-
onAfterHierarchy(context, writer
|
|
59
|
+
onAfterHierarchy(context, writer: USDWriter) {
|
|
70
60
|
if (this.behaviours?.length) {
|
|
71
61
|
|
|
72
62
|
// this.combineBehavioursWithSameTapActions();
|
|
@@ -7,7 +7,7 @@ import { RegisteredAnimationInfo, UsdzAnimation } from "../Animation";
|
|
|
7
7
|
import { getWorldPosition, getWorldQuaternion, getWorldScale, setWorldPosition, setWorldQuaternion, setWorldScale } from "../../../../../engine/engine_three_utils";
|
|
8
8
|
|
|
9
9
|
import { Object3D, Material, Vector3, Quaternion, AnimationAction } from "three";
|
|
10
|
-
import { USDObject } from "../../ThreeUSDZExporter";
|
|
10
|
+
import { USDDocument, USDObject } from "../../ThreeUSDZExporter";
|
|
11
11
|
|
|
12
12
|
import { BehaviorExtension, UsdzBehaviour } from "./Behaviour";
|
|
13
13
|
import { ActionBuilder, ActionModel, BehaviorModel, IBehaviorElement, MotionType, Space, TriggerBuilder } from "./BehavioursBuilder";
|
|
@@ -44,7 +44,7 @@ export class ChangeTransformOnClick extends Behaviour implements IPointerClickHa
|
|
|
44
44
|
|
|
45
45
|
const thisScale = getWorldScale(this.object).clone();
|
|
46
46
|
const targetScale = getWorldScale(this.target).clone();
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
const dist = thisPos.distanceTo(targetPos);
|
|
49
49
|
const rotDist = thisRot.angleTo(targetRot);
|
|
50
50
|
const scaleDist = thisScale.distanceTo(targetScale);
|
|
@@ -63,10 +63,10 @@ export class ChangeTransformOnClick extends Behaviour implements IPointerClickHa
|
|
|
63
63
|
|
|
64
64
|
t01 += this.context.time.deltaTime / this.duration;
|
|
65
65
|
if (t01 > 1) t01 = 1;
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
// apply ease-in-out
|
|
68
68
|
// https://easings.net/
|
|
69
|
-
eased =
|
|
69
|
+
eased = t01 < 0.5 ? 4 * t01 * t01 * t01 : 1 - Math.pow(-2 * t01 + 2, 3) / 2;
|
|
70
70
|
|
|
71
71
|
this.targetPos.lerpVectors(thisPos, targetPos, eased);
|
|
72
72
|
this.targetRot.slerpQuaternions(thisRot, targetRot, eased);
|
|
@@ -83,7 +83,7 @@ export class ChangeTransformOnClick extends Behaviour implements IPointerClickHa
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
private *moveRelative() {
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
if (!this.target || !this.object) return;
|
|
88
88
|
|
|
89
89
|
const thisPos = this.object.position.clone();
|
|
@@ -107,10 +107,10 @@ export class ChangeTransformOnClick extends Behaviour implements IPointerClickHa
|
|
|
107
107
|
|
|
108
108
|
t01 += this.context.time.deltaTime / this.duration;
|
|
109
109
|
if (t01 > 1) t01 = 1;
|
|
110
|
-
|
|
110
|
+
|
|
111
111
|
// apply ease-in-out
|
|
112
112
|
// https://easings.net/
|
|
113
|
-
eased =
|
|
113
|
+
eased = t01 < 0.5 ? 4 * t01 * t01 * t01 : 1 - Math.pow(-2 * t01 + 2, 3) / 2;
|
|
114
114
|
|
|
115
115
|
this.object.position.lerpVectors(thisPos, this.targetPos, eased);
|
|
116
116
|
this.object.quaternion.slerpQuaternions(thisRot, this.targetRot, eased);
|
|
@@ -120,7 +120,7 @@ export class ChangeTransformOnClick extends Behaviour implements IPointerClickHa
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
this.coroutine = null;
|
|
123
|
-
}
|
|
123
|
+
}
|
|
124
124
|
|
|
125
125
|
onPointerClick() {
|
|
126
126
|
if (this.coroutine) this.stopCoroutine(this.coroutine);
|
|
@@ -313,11 +313,12 @@ export class SetActiveOnClick extends Behaviour implements IPointerClickHandler,
|
|
|
313
313
|
hideClickedObject = true;
|
|
314
314
|
targetState = !this.target.visible;
|
|
315
315
|
|
|
316
|
-
|
|
316
|
+
if (!this.selfModel.parent || this.selfModel.parent.isEmpty())
|
|
317
|
+
USDDocument.createEmptyParent(this.selfModel);
|
|
318
|
+
|
|
317
319
|
this.toggleModel = this.selfModel.clone();
|
|
318
320
|
this.toggleModel.name += "_toggle";
|
|
319
|
-
|
|
320
|
-
this.selfModel.parent.add(this.toggleModel);
|
|
321
|
+
this.selfModel.parent!.add(this.toggleModel);
|
|
321
322
|
}
|
|
322
323
|
|
|
323
324
|
const sequence: ActionModel[] = [];
|
|
@@ -344,8 +345,8 @@ export class SetActiveOnClick extends Behaviour implements IPointerClickHandler,
|
|
|
344
345
|
ActionBuilder.sequence(...toggleSequence)
|
|
345
346
|
));
|
|
346
347
|
|
|
347
|
-
ext.addBehavior(new BehaviorModel("HideOnStart_" + this.gameObject.name,
|
|
348
|
-
TriggerBuilder.sceneStartTrigger(),
|
|
348
|
+
ext.addBehavior(new BehaviorModel("HideOnStart_" + this.gameObject.name,
|
|
349
|
+
TriggerBuilder.sceneStartTrigger(),
|
|
349
350
|
ActionBuilder.fadeAction(this.toggleModel, 0, false)
|
|
350
351
|
));
|
|
351
352
|
}
|
|
@@ -363,8 +364,8 @@ export class HideOnStart extends Behaviour implements UsdzBehaviour {
|
|
|
363
364
|
|
|
364
365
|
createBehaviours(ext, model, _context) {
|
|
365
366
|
if (model.uuid === this.gameObject.uuid)
|
|
366
|
-
ext.addBehavior(new BehaviorModel("HideOnStart_" + this.gameObject.name,
|
|
367
|
-
TriggerBuilder.sceneStartTrigger(),
|
|
367
|
+
ext.addBehavior(new BehaviorModel("HideOnStart_" + this.gameObject.name,
|
|
368
|
+
TriggerBuilder.sceneStartTrigger(),
|
|
368
369
|
ActionBuilder.fadeAction(model, 0, false)
|
|
369
370
|
));
|
|
370
371
|
}
|
|
@@ -394,8 +395,7 @@ export class EmphasizeOnClick extends Behaviour implements UsdzBehaviour {
|
|
|
394
395
|
createBehaviours(ext, model, _context) {
|
|
395
396
|
if (!this.target) return;
|
|
396
397
|
|
|
397
|
-
if (model.uuid === this.gameObject.uuid)
|
|
398
|
-
{
|
|
398
|
+
if (model.uuid === this.gameObject.uuid) {
|
|
399
399
|
const emphasize = new BehaviorModel("emphasize " + this.name,
|
|
400
400
|
TriggerBuilder.tapTrigger(this.gameObject),
|
|
401
401
|
ActionBuilder.emphasize(this.target, this.duration, this.motionType, undefined, "basic"),
|
|
@@ -417,7 +417,7 @@ export class PlayAnimationOnClick extends Behaviour implements IPointerClickHand
|
|
|
417
417
|
|
|
418
418
|
@serializable()
|
|
419
419
|
stateName?: string;
|
|
420
|
-
|
|
420
|
+
|
|
421
421
|
@serializable()
|
|
422
422
|
stateNameAfterPlaying?: string;
|
|
423
423
|
|
|
@@ -486,7 +486,7 @@ export class PlayAnimationOnClick extends Behaviour implements IPointerClickHand
|
|
|
486
486
|
|
|
487
487
|
createAnimation(ext, model, _context) {
|
|
488
488
|
if (this.target && this.animator) {
|
|
489
|
-
|
|
489
|
+
|
|
490
490
|
const state = this.animator?.runtimeAnimatorController?.findState(this.stateName);
|
|
491
491
|
this.stateAnimationModel = model;
|
|
492
492
|
this.stateAnimation = ext.registerAnimation(this.target, state?.motion.clip);
|
|
@@ -74,7 +74,7 @@ function resolve(targetObject: Target, document: USDDocument): string {
|
|
|
74
74
|
let obj = targetObject[i];
|
|
75
75
|
if (typeof obj === "string")
|
|
76
76
|
str += obj;
|
|
77
|
-
else if (
|
|
77
|
+
else if (typeof obj === "object") {
|
|
78
78
|
//@ts-ignore
|
|
79
79
|
if (obj.isObject3D) {
|
|
80
80
|
//@ts-ignore
|
|
@@ -436,7 +436,7 @@ export class ActionBuilder {
|
|
|
436
436
|
act.tokenId = "Emphasize";
|
|
437
437
|
act.duration = duration;
|
|
438
438
|
act.style = style ?? "basic";
|
|
439
|
-
act.motionType = MotionType[motionType];
|
|
439
|
+
act.motionType = MotionType[motionType];
|
|
440
440
|
act.moveDistance = moveDistance;
|
|
441
441
|
return act;
|
|
442
442
|
}
|
|
@@ -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,9 +194,10 @@ export class RectTransform extends BaseUIComponent implements IRectTransform, IR
|
|
|
191
194
|
|
|
192
195
|
const uiobject = this.shadowComponent;
|
|
193
196
|
if (!uiobject) return;
|
|
194
|
-
if (
|
|
195
|
-
|
|
196
|
-
|
|
197
|
+
if (this.gameObject.parent)
|
|
198
|
+
this._parentRectTransform = GameObject.getComponentInParent(this.gameObject.parent, RectTransform) as RectTransform;
|
|
199
|
+
else
|
|
200
|
+
this._parentRectTransform = undefined;
|
|
197
201
|
this._transformNeedsUpdate = false;
|
|
198
202
|
this.lastMatrix.copy(this.gameObject.matrix);
|
|
199
203
|
|
|
@@ -229,7 +233,7 @@ export class RectTransform extends BaseUIComponent implements IRectTransform, IR
|
|
|
229
233
|
else {
|
|
230
234
|
// We have to rotate the canvas when it's in worldspace
|
|
231
235
|
const canvas = this.Root as any as ICanvas;
|
|
232
|
-
if (
|
|
236
|
+
if (!canvas.screenspace) uiobject.rotation.y = Math.PI;
|
|
233
237
|
}
|
|
234
238
|
|
|
235
239
|
// iterate other components on this object that might need to know about the transform change
|