Skip to content

Commit d227fb0

Browse files
authored
fix: Explosive growth mode (#1146)
* fix: Css styles * feat: Create a new GizmoManager to use babylon 8 features * refactor: Enhance transform component handling in BabylonJS - Removed unnecessary gizmo restoration logic. - Initialized rotation quaternion for new entities and ensured proper handling of existing entities' rotation. - Updated parenting logic to maintain world transform during reparenting. - Added normalization for rotation quaternions to ensure validity. - Improved comments for clarity on transformation operations. * refactor: Update GizmoManager import and fix alignment method calls * fix: Rotation Gizmo * fix: Position Gizmo * fix: Scale Gizmo * fix: FreeGizmo behaviour * fix: Use isGizmoWorldAligned to apply local or global align to entities * fix: Remove unused code * fix: Rotations with snap * fix: Children local rotation * fix: Update FreeGizmo implementation * fix: Remove unrequired code * fix: Comments * fix: Rotation gizmo snapping and refactor code * fix: Gizmo syncing when updating entities Transform * fix: Detect snap changes * fix: FreeGizmo mesh dragging * fix: Lint issue * fix: Rotation update transform only on drag end * fix: Gizmos works only with the LEFT_CLICK * fix: tests * fix: lint * fix: Remove unused methods in tests
1 parent 270677a commit d227fb0

18 files changed

Lines changed: 2240 additions & 198 deletions

File tree

packages/@dcl/inspector/src/components/EntityInspector/AdminToolkitView/VideoControl/VideoControl.css

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@
44
flex-direction: column;
55
gap: 16px;
66
width: 100%;
7+
}
8+
9+
.VideoControl .Title {
10+
font-size: 14px;
11+
font-weight: 400;
12+
color: var(--base-04);
13+
}
14+
15+
.VideoControl .ScreenSetup {
16+
display: flex;
17+
flex-direction: row;
18+
margin-bottom: 12px;
19+
}
720

8-
.Title {
9-
font-size: 14px;
10-
font-weight: 400;
11-
color: var(--base-04);
12-
}
13-
.ScreenSetup {
14-
display: flex;
15-
flex-direction: row;
16-
.Label {
17-
margin-left: 8px;
18-
text-wrap: wrap;
19-
width: 80%;
20-
}
21-
margin-bottom: 12px;
22-
}
21+
.VideoControl .ScreenSetup label {
22+
margin-left: 8px;
23+
text-wrap: wrap;
24+
width: 80%;
2325
}
2426

2527
/* Checkbox group */

packages/@dcl/inspector/src/components/EntityInspector/SmartItemBasicView/VideoScreenBasicView/VideoScreenBasicView.css

Lines changed: 58 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,63 @@
22
display: flex;
33
flex-direction: column;
44
gap: 16px;
5+
}
6+
7+
.VideoScreenBasicViewInspector .Info {
8+
display: flex;
9+
flex-direction: row;
10+
margin-bottom: 8px;
11+
}
12+
13+
.VideoScreenBasicViewInspector .Info label {
14+
margin-left: 8px;
15+
text-wrap: wrap;
16+
width: 80%;
17+
}
18+
19+
.VideoScreenBasicViewInspector .Title {
20+
font-size: 14px;
21+
font-weight: 400;
22+
}
23+
24+
.VideoScreenBasicViewInspector .Divider {
25+
height: 1px;
26+
background-color: var(--base-14);
27+
}
28+
29+
.VideoScreenBasicViewInspector .DefaultMediaSourcesDropdown {
30+
margin-top: 6px;
31+
max-width: 150px;
32+
}
33+
34+
.VideoScreenBasicViewInspector .DefaultMediaSourcesDropdown .OptionList {
35+
overflow: hidden;
36+
}
37+
38+
.VideoScreenBasicViewInspector .PanelSection {
39+
background-color: var(--background-dark);
40+
}
41+
42+
.VideoScreenBasicViewInspector .PlayBack {
43+
margin-top: 10px;
44+
margin-bottom: 10px;
45+
}
46+
47+
.VideoScreenBasicViewInspector .PlayBack .CheckboxContainer {
48+
margin-top: 10px;
49+
display: flex;
50+
flex-direction: row;
51+
}
52+
53+
.VideoScreenBasicViewInspector .LiveStreamSection .content {
54+
display: flex;
55+
flex-direction: row;
56+
margin-bottom: 10px;
57+
}
558

6-
.Info {
7-
display: flex;
8-
flex-direction: row;
9-
margin-bottom: 8px;
10-
.Label {
11-
margin-left: 8px;
12-
text-wrap: wrap;
13-
width: 80%;
14-
}
15-
}
16-
17-
.Title {
18-
font-size: 14px;
19-
font-weight: 400;
20-
}
21-
22-
.Divider {
23-
height: 1px;
24-
background-color: var(--base-14);
25-
}
26-
27-
.DefaultMediaSourcesDropdown {
28-
margin-top: 6px;
29-
max-width: 150px;
30-
31-
.OptionList {
32-
overflow: hidden;
33-
}
34-
}
35-
.PanelSection {
36-
background-color: var(--background-dark);
37-
}
38-
.PlayBack {
39-
margin-top: 10px;
40-
margin-bottom: 10px;
41-
.CheckboxContainer {
42-
margin-top: 10px;
43-
display: flex;
44-
flex-direction: row;
45-
}
46-
}
47-
48-
.LiveStreamSection .content {
49-
display: flex;
50-
flex-direction: row;
51-
margin-bottom: 10px;
52-
.Label {
53-
text-wrap: wrap;
54-
margin-left: 8px;
55-
font-weight: 400;
56-
font-size: 11px;
57-
}
58-
}
59+
.VideoScreenBasicViewInspector .LiveStreamSection .content .Label {
60+
text-wrap: wrap;
61+
margin-left: 8px;
62+
font-weight: 400;
63+
font-size: 11px;
5964
}

packages/@dcl/inspector/src/components/Toolbar/Gizmos/Gizmos.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ export const Gizmos = withSdk(({ sdk }) => {
4848
useHotkey(['X'], handleScaleGizmo)
4949
useHotkey(['F'], handleFreeGizmo)
5050

51-
const { isPositionGizmoWorldAligned, setPositionGizmoWorldAligned } = useGizmoAlignment()
51+
const { isGizmoWorldAligned, setGizmoWorldAligned } = useGizmoAlignment()
5252

5353
const disableGizmos = !entity
5454

5555
const SnapToggleIcon = isEnabled ? BiCheckboxChecked : BiCheckbox
56-
const PositionAlignmentIcon = isPositionGizmoWorldAligned ? BiCheckboxChecked : BiCheckbox
56+
const WorldAlignmentIcon = isGizmoWorldAligned ? BiCheckboxChecked : BiCheckbox
5757

5858
const ref = useOutsideClick(handleClosePanel)
5959

@@ -100,13 +100,7 @@ export const Gizmos = withSdk(({ sdk }) => {
100100
</div>
101101
<div className="title">
102102
<label>Align to world</label>
103-
</div>
104-
<div className="alignment">
105-
<label>Position</label>
106-
<PositionAlignmentIcon
107-
className="icon"
108-
onClick={() => setPositionGizmoWorldAligned(!isPositionGizmoWorldAligned)}
109-
/>
103+
<WorldAlignmentIcon className="icon" onClick={() => setGizmoWorldAligned(!isGizmoWorldAligned)} />
110104
</div>
111105
</div>
112106
</div>

packages/@dcl/inspector/src/components/Warnings/MultipleEntitiesSelected/MultipleEntitiesSelected.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import { Warning } from '../Warning'
1010
const MultiSelectEntities: React.FC = withSdk(({ sdk }) => {
1111
const selectedEntity = useSelectedEntity()
1212
const [selection] = useComponentValue(selectedEntity || ROOT, sdk.components.Selection)
13-
const { isPositionGizmoAlignmentDisabled } = useGizmoAlignment()
13+
const { isGizmoWorldAlignmentDisabled } = useGizmoAlignment()
1414
const areMultipleEntitiesSelected = sdk.operations.getSelectedEntities().length > 1
1515
if (
1616
selectedEntity &&
1717
selection.gizmo === GizmoType.POSITION &&
18-
isPositionGizmoAlignmentDisabled &&
18+
isGizmoWorldAlignmentDisabled &&
1919
areMultipleEntitiesSelected
2020
) {
2121
return (

packages/@dcl/inspector/src/components/Warnings/RotationGizmoLocalAlignmentDisabled/RotationGizmoLocalAlignmentDisabled.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { GizmoType } from '../../../lib/utils/gizmo'
1010
const RotationGizmoLocalAlignmentDisabled: React.FC = withSdk(({ sdk }) => {
1111
const selectedEntity = useSelectedEntity()
1212
const [selection] = useComponentValue(selectedEntity || ROOT, sdk.components.Selection)
13-
const { isRotationGizmoAlignmentDisabled } = useGizmoAlignment()
14-
if (selectedEntity && selection.gizmo === GizmoType.ROTATION && isRotationGizmoAlignmentDisabled) {
13+
const { isGizmoWorldAlignmentDisabled } = useGizmoAlignment()
14+
if (selectedEntity && selection.gizmo === GizmoType.ROTATION && isGizmoWorldAlignmentDisabled) {
1515
return (
1616
<Warning
1717
title={

packages/@dcl/inspector/src/hooks/editor/useGizmoAlignment.spec.ts

Lines changed: 21 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,9 @@ const gizmoManagerEvents = mitt()
1313
const mockEntity = 0 as Entity
1414
const gizmoManagerMock = {
1515
getEntity: jest.fn().mockReturnValue({ entityId: mockEntity } as EcsEntity),
16-
isPositionGizmoWorldAligned: jest.fn().mockReturnValue(true),
17-
isRotationGizmoWorldAligned: jest.fn().mockReturnValue(true),
18-
isRotationGizmoAlignmentDisabled: jest.fn().mockReturnValue(false),
19-
isPositionGizmoAlignmentDisabled: jest.fn().mockReturnValue(false),
20-
setPositionGizmoWorldAligned: jest.fn(),
21-
setRotationGizmoWorldAligned: jest.fn(),
22-
fixRotationGizmoAlignment: jest.fn(),
23-
fixPositionGizmoAlignment: jest.fn(),
16+
isGizmoWorldAligned: jest.fn().mockReturnValue(true),
17+
isGizmoWorldAlignmentDisabled: jest.fn().mockReturnValue(false),
18+
setGizmoWorldAligned: jest.fn(),
2419
onChange: jest.fn().mockImplementation((cb) => gizmoManagerEvents.on('*', cb))
2520
}
2621
createGizmoManagerMock.mockReturnValue(gizmoManagerMock as unknown as ReturnType<typeof createGizmoManager>)
@@ -60,71 +55,51 @@ describe('useGizmoAlignment', () => {
6055
afterEach(() => {
6156
useSdkMock.mockClear()
6257
createGizmoManagerMock.mockClear()
63-
gizmoManagerMock.isPositionGizmoWorldAligned.mockClear()
64-
gizmoManagerMock.isRotationGizmoWorldAligned.mockClear()
65-
gizmoManagerMock.setPositionGizmoWorldAligned.mockClear()
66-
gizmoManagerMock.setRotationGizmoWorldAligned.mockClear()
58+
gizmoManagerMock.isGizmoWorldAligned.mockClear()
59+
gizmoManagerMock.isGizmoWorldAlignmentDisabled.mockClear()
60+
gizmoManagerMock.setGizmoWorldAligned.mockClear()
6761
gizmoManagerMock.onChange.mockClear()
6862
gizmoManagerEvents.all.clear()
6963
engineEvents.all.clear()
7064
})
7165
describe('When the hook is mounted ', () => {
7266
it('should sync the state with the gizmo manager', () => {
7367
const { result } = renderHook(() => useGizmoAlignment())
74-
const { isPositionGizmoWorldAligned, isRotationGizmoWorldAligned } = result.current
75-
expect(isPositionGizmoWorldAligned).toBe(true)
76-
expect(isRotationGizmoWorldAligned).toBe(true)
77-
expect(gizmoManagerMock.isPositionGizmoWorldAligned).toHaveBeenCalled()
78-
expect(gizmoManagerMock.isRotationGizmoWorldAligned).toHaveBeenCalled()
68+
const { isGizmoWorldAligned } = result.current
69+
expect(isGizmoWorldAligned).toBe(true)
70+
expect(gizmoManagerMock.isGizmoWorldAligned).toHaveBeenCalled()
7971
})
8072
it('should add a listener for the onChange event of the gizmoManager', () => {
8173
renderHook(() => useGizmoAlignment())
8274
expect(gizmoManagerMock.onChange).toHaveBeenCalled()
8375
})
8476
it('should not update the renderer', () => {
8577
renderHook(() => useGizmoAlignment())
86-
expect(gizmoManagerMock.setPositionGizmoWorldAligned).not.toHaveBeenCalled()
87-
expect(gizmoManagerMock.setRotationGizmoWorldAligned).not.toHaveBeenCalled()
78+
expect(gizmoManagerMock.setGizmoWorldAligned).not.toHaveBeenCalled()
8879
})
8980
})
9081
describe('When the hook state is changed ', () => {
9182
it('should update the renderer', () => {
9283
const { result } = renderHook(() => useGizmoAlignment())
93-
const { setPositionGizmoWorldAligned, setRotationGizmoWorldAligned } = result.current
94-
expect(result.current.isPositionGizmoWorldAligned).toBe(true)
95-
expect(result.current.isRotationGizmoWorldAligned).toBe(true)
96-
gizmoManagerMock.isPositionGizmoWorldAligned.mockReturnValue(true)
97-
gizmoManagerMock.isRotationGizmoWorldAligned.mockReturnValue(true)
84+
const { setGizmoWorldAligned } = result.current
85+
expect(result.current.isGizmoWorldAligned).toBe(true)
86+
gizmoManagerMock.isGizmoWorldAligned.mockReturnValue(true)
9887
act(() => {
99-
setPositionGizmoWorldAligned(false)
100-
setRotationGizmoWorldAligned(false)
88+
setGizmoWorldAligned(false)
10189
})
102-
expect(result.current.isPositionGizmoWorldAligned).toBe(false)
103-
expect(result.current.isRotationGizmoWorldAligned).toBe(false)
104-
expect(gizmoManagerMock.setPositionGizmoWorldAligned).toHaveBeenCalledWith(false)
105-
expect(gizmoManagerMock.setRotationGizmoWorldAligned).toHaveBeenCalledWith(false)
90+
expect(result.current.isGizmoWorldAligned).toBe(false)
91+
expect(gizmoManagerMock.setGizmoWorldAligned).toHaveBeenCalledWith(false)
10692
})
10793
})
10894
describe('When a change happens in the renderer', () => {
10995
it('should update the hook state', () => {
11096
renderHook(() => useGizmoAlignment())
111-
gizmoManagerMock.isPositionGizmoWorldAligned.mockClear()
112-
gizmoManagerMock.isRotationGizmoWorldAligned.mockClear()
113-
gizmoManagerMock.isRotationGizmoAlignmentDisabled.mockReset()
114-
gizmoManagerMock.isRotationGizmoAlignmentDisabled.mockReturnValue(true)
97+
gizmoManagerMock.isGizmoWorldAligned.mockClear()
98+
gizmoManagerMock.isGizmoWorldAlignmentDisabled.mockReset()
99+
gizmoManagerMock.isGizmoWorldAlignmentDisabled.mockReturnValue(true)
115100
gizmoManagerEvents.emit('*')
116-
expect(gizmoManagerMock.isPositionGizmoWorldAligned).toHaveBeenCalled()
117-
expect(gizmoManagerMock.isRotationGizmoWorldAligned).toHaveBeenCalled()
118-
expect(gizmoManagerMock.isRotationGizmoAlignmentDisabled).toHaveBeenCalled()
119-
})
120-
})
121-
describe('When a change happens in the engine', () => {
122-
it('should update the renderer', () => {
123-
engineEvents.all.clear()
124-
renderHook(() => useGizmoAlignment())
125-
expect(gizmoManagerMock.fixRotationGizmoAlignment).not.toHaveBeenCalled()
126-
engineEvents.emit('*')
127-
expect(gizmoManagerMock.fixRotationGizmoAlignment).toHaveBeenCalledWith(mockEvent.value)
101+
expect(gizmoManagerMock.isGizmoWorldAligned).toHaveBeenCalled()
102+
expect(gizmoManagerMock.isGizmoWorldAlignmentDisabled).toHaveBeenCalled()
128103
})
129104
})
130105
})

0 commit comments

Comments
 (0)